【问题标题】:Cordova phonegap android application does not exitCordova phonegap android 应用程序不退出
【发布时间】:2015-05-07 08:49:25
【问题描述】:

我是phonegap cordova development的新手。我在cordova的google帮助下做了一个演示应用程序。这里我选择了一个名为exitapp的按钮并调用了函数navigator.app.exitApp()function.here它工作正常但是如果我在其中添加一些方法mainActivity,java 文件然后navigator.app.exitApp() 函数不起作用。 我用过

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>

在 html 页面中。

我的活动代码是。

 package com.example.hello;
 import com.acl.paychamp.util.DecryptData;
 import com.example.hello.R;

 public class MainActivity 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();
    setContentView(R.layout.main);
    cwv = (CordovaWebView) findViewById(R.id.view);     
    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://abcd.com/pr?
     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/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);
    }
    }
   }

【问题讨论】:

    标签: android cordova jquery-mobile phonegap-plugins


    【解决方案1】:

    如果您的意思是最小化应用程序进入后台(不是活动应用程序,但它仍在运行的应用程序列表中)。如果这就是您的意思,请注意这是 Android 和许多移动操作系统中的正常行为。

    终止(如果您愿意,可以退出)应用程序不受应用程序开发人员的控制。它完全由操作系统(在本例中为 Android)管理。因此,您所拥有的是移动操作系统下应用程序的正常行为。

    来源:navigator.app.exitapp() not working in android device

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 1970-01-01
      相关资源
      最近更新 更多