簡體   English   中英

單擊后退按鈕時,Phonegap Android應用程序崩潰

[英]Phonegap Android Application Crash when clicking back button

我正在使用cordova 3.3.0。在我的應用程序中,當我單擊“后退”按鈕時,一旦應用程序啟動,應用程序就會崩潰。

我已經在“主要活動”中處理了后退按鈕動作,但結果相同。

以下是崩潰。

03-19 14:40:53.254: E/AndroidRuntime(23449): FATAL EXCEPTION: main 
03-19 14:40:53.254: E/AndroidRuntime(23449): Process: com.example.example, PID: 23449 
03-19 14:40:53.254: E/AndroidRuntime(23449): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@420b9d30 is not valid; is your activity running? 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.view.ViewRootImpl.setView(ViewRootImpl.java:536) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.app.Dialog.show(Dialog.java:286) 03-19 14:40:53.254: E/AndroidRuntime(23449):    at org.apache.cordova.DroidGap$5.run(DroidGap.java:1038) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.os.Handler.handleCallback(Handler.java:733) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.os.Handler.dispatchMessage(Handler.java:95) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at android.os.Looper.loop(Looper.java:136) 03-19 14:40:53.254: E/AndroidRuntime(23449):     at android.app.ActivityThread.main(ActivityThread.java:5017) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at java.lang.reflect.Method.invokeNative(Native Method) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at java.lang.reflect.Method.invoke(Method.java:515) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
03-19 14:40:53.254: E/AndroidRuntime(23449):    at dalvik.system.NativeStart.main(Native Method)

提前致謝

公共類MainActivity擴展了DroidGap {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("loadUrlTimeoutValue", 60000); 
     new CordovaWebClient(this, appView);
    super.loadUrl("file:///android_asset/www/index.html");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

public void onReceivedSslError(WebView view,
                SslErrorHandler handler, SslError error) {
Log.e("Error", "Received SSL error"+ error.toString());
handler.proceed();
}
@Override
public void init() {
    Log.e(TAG, "init()");
    CordovaWebView webView = new CordovaWebView(MainActivity.this);
    CordovaWebViewClient webViewClient;
    if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
    {
        webViewClient = new CordovaWebViewClient(this, webView);
    }
    else
    {
        webViewClient = new IceCreamCordovaWebViewClient(this, webView);
    }
    this.init(webView, webViewClient, new MyCordovaChromeClient(this, webView));
}

private class MyCordovaChromeClient extends CordovaChromeClient{
    private CordovaInterface cordova;
    public MyCordovaChromeClient(CordovaInterface ctx, CordovaWebView app) {
        super(ctx, app);
        this.cordova = ctx;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM