Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9098019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:15:44+00:00 2026-06-17T00:15:44+00:00

On some Android devices, my Cordova-based app crashes around the time I prompt the

  • 0

On some Android devices, my Cordova-based app crashes around the time I prompt the user if they’d like to receive notifications, which happens on the first app startup. Here’s a typical stack trace:

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@<i>[eight hex digits]</i> is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:535)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:241)
at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
at org.apache.cordova.Notification$2.run(Notification.java:245)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

The JavaScript code:

navigator.notification.confirm(
     'Do you wish to receive push notifications?',
     function(btnIndex) {
         if (btnIndex == 1) {
             push.enablePush();
             localStorage.pushAsked = true;
         } else {
             push.disablePush();
             localStorage.pushAsked = true;
         }
     },
     'Push Notifications',
     'Yes,No'
);

Any ideas? I don’t know which devices or Android versions are affected, but that question is out there to those who have reported it.

I’m using Cordova 2.2.0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:15:45+00:00Added an answer on June 17, 2026 at 12:15 am

    This is because you are trying to display alert dialog while the activity is finishing.

    You can subclass CordovaChromeClient and check for activity.isFinishing() on onJsAlert()

    I have created a project on Github that solves this bug:
    https://github.com/kruyvanna/CordovaAlertBug_Android

    You can see an example below.

    class CordovaOnJsAlertBug extends DroidGap{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
    
    @Override
    public void init() {
        Log.e(TAG, "init()");
        CordovaWebView webView = new CordovaWebView(CordovaOnJsAlertBug.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;
        }
    
    
        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            if(cordova.getActivity().isFinishing()){
                Log.w(TAG, "Trying to alert while activity is finishing!! -> ignore");
                result.cancel();
                return true;
            }
    
            return super.onJsAlert(view, url, message, result);
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like some Android devices have Share option. Which is available when user go
I have some virtual devices Android 2.2, 4.0.3, Google APIs 2.2... They work fine.
Some Android devices don't have Android Market, like Korea, etc. Is it possible to
I cannot get some Android devices to wake up using the AlarmManager. Following the
I need to store locally on android devices some images I get from the
I get some wierd logs, which obviously only occurs on Android-Devices with Versions below
I have android device with root and i try to implement some small app.
On some android devices in mapview google logo are shown as gray or red
How to create our own wifi hotspot. I need some android devices connect to
can some owners of Android devices please come forward and publish the data that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.