cordova - PhoneGap Android Plugin - close the plugin Activity -


I have a PhoneGap Android plugin I wrote to open a second activity and there:

 < Code> Cordoba KgetActivity () RunOnUiThread (new Runnable () {@Override public void run () {REFERENCES = cordova.getActivity () getApplicationContext () ;. Intent intent = new Intent (context, secondActivity.class); cordova.getActivity () Start activity (intent);}});  

Now I want to stop the activity with a button and send the plugin results to Javascript, but I am not able to turn off the activity and go back to the phonegap application - I How can I do this?

I hope someone can help me, thanks for answering all the questions.

In your plugin, startActivityForResult use CordovaInterface class of Android StartActivity instead of:

  this.cordova.startActivityForResult (this, intent, 0);  

(0 is an activity that is used to identify the activity initiated, if you need to start many activities, then use other numbers)

in its activity back to the plugin results add the following:

  public void return result (int code, string result) {intent Wapasiintent = new intent ( ); Return Intent InputXX ("result", result); SetResult (code, return unit); End(); }  

When you representing your activity to get out of you

And finally RESULT_CANCELED your plugin or RESULT_OK and a string you want to go This function says. Class, add the following function:

  public void OnActivityResult (integer requestCode, integer resultCode, Intent intent) {switch (RequestCode) {case 0: // int matching integer suplied when activity started to if ( ResultCode == android.app.Activity.RESULT_OK) {// Returning string for JavaScript string result in case of success = intent.getStringExtra ("Result"); This.callbackContext.success (results); } Else {// code error string message = intent.getStringExtra ("result") was started in the case of; This.callbackContext.error (message); }          break; Default: Break; }}  

Hope you did what you wanted.


Comments