I created a cordova plugin (3.3.0) that launches an action and waits for a result. But the callback (simple alert) is not a call until the second plugin is enabled. Here is the code:
public boolean execute(String action, final JSONArray args, final CallbackContext cbc) throws JSONException { this.callbackContext = cbc; try { Intent i = new Intent(cordova.getActivity(), ActivityCamera.class); this.cordova.setActivityResultCallback(PhotoMokoPlugin.this); this.cordova.startActivityForResult(PhotoMokoPlugin.this, i, 0); PluginResult pr = new PluginResult(PluginResult.Status.NO_RESULT); pr.setKeepCallback(true); callbackContext.sendPluginResult(pr); return true; } catch (JSONException e) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return false; } } @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); try { callbackContext.success(json.toString());
Only ActivityCamera setResult with new Intent avec finish() ;
For example: if I click the button that calls the plugin, nothing happens. I click a second time, a warning message appears and nothing else (usually another warning) ...
Do you have any ideas?
Tell me if more code is needed.
EDIT: Updating Cordoba did not solve the problem.
EDIT 2: The problem seems to come from this code:
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }
If I delete it, the call will be called for the first time. Is there a problem?
source share