Cordoba CLI Phone Gap The app navigator.app.exit Function does not work

I am New Cordova phoneGap Development. I am impliment A simple example of Cordova Helloworld, it works fine and also clicks on the Navigator.app.exit, working fine.i, includes some code in My MainActivity After That Navigator.app.exit funtion not call on the button click and also back click on. Please give me some suggestions Thank you.

    public class CordovaApp extends CordovaActivity implements   
   CordovaInterface {
  CordovaWebView cwv;
  private final ExecutorService threadPool =  
  Executors.newCachedThreadPool();
  private CordovaPlugin activityResultCallback;
  public static final String PASSKEY = "s407iejl";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();
    //super.appView.getSettings().setJavaScriptEnabled(true);
    MyClass mc = new MyClass(this, appView);
    appView.addJavascriptInterface(mc, "MyCls");
    setContentView(R.layout.main);
    cwv = (CordovaWebView) findViewById(R.id.buyView);      
    cwv.loadUrl(this.launchUrl);
     }




  @Override
  public void startActivityForResult(CordovaPlugin command, Intent intent, 
         int requestCode) {
    this.activityResultCallback = command;

    // Start activity
    super.startActivityForResult(intent, requestCode);
}

  @Override
  public void setActivityResultCallback(CordovaPlugin plugin) {
    this.activityResultCallback = plugin;
  }

  @Override
  public Activity getActivity() {
    return this;
  }

  @Override
  public Object onMessage(String id, Object data) {
    try {
        URI uri = new URI(data.toString());
        if (uri.toString().contains("http://asdf.com/proces?
             param=")) {

            String encryptedText = uri.getQuery().split("=")[1];
            JSONObject jObj = DecryptData.getDecryptedJson(encryptedText,
          PASSKEY);
            Log.i("CordovaApp", jObj.get("msg").toString());
            Log.i("CordovaApp", jObj.get("trxid").toString());
            cwv.loadUrl("file:///android_asset/www/payment_status.htm? 
       resparam="+encryptedText);
        }
    } catch (Exception use) {
    }
    return null;
   }

  @Override
  public ExecutorService getThreadPool() {
    return threadPool;

  }

 @Override
   protected void onActivityResult(final int requestCode, final int 
   resultCode,  final Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    CordovaPlugin callback = this.activityResultCallback;
    if (callback != null) {
        callback.onActivityResult(requestCode, resultCode, intent);
    }
   }
 }
+4
source share

Source: https://habr.com/ru/post/1585033/


All Articles