I've created a cordova plugin (3.3.0), which launch an activity and waits for a result. But the callback (simple alert) isn't call until a lauch the plugin a second time. 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()); // Doesn't matter if success or error
}
catch (JSONException e)
{
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
}
}
The ActivityCamera only setResult
with a new Intent
avec finish()
;
For example : If I click on a button which call the plugin, nothing happens. I click a second time, the alert message is displayed and nothing more (normally another alert)...
Do you have any idea ?
Tell me if more code is needed.
EDIT : Updating Cordova didn't solved 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 remove it, the callback is called the first time. Is there an issue ?