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 7556297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:49:56+00:00 2026-05-30T11:49:56+00:00

I am using C2DM together with PhoneGap. When I receive a C2DM message, I

  • 0

I am using C2DM together with PhoneGap. When I receive a C2DM message, I display a notification (via NotificationManager). When the user selects the notification then my application receives an intent. In that case I want to activate a page within my jquery-mobile webapp.

Therefore I overrode the onNewIntent event to store the intent:

@Override
protected void onNewIntent(final Intent intent)
{
    super.onNewIntent(intent);
    setIntent(intent);
}

Then, in onResume I activated the correct page if the intent was from C2DM:

@Override
protected void onResume()
{
    super.onResume();

    // read possible argument
    boolean showMessage = getIntent().getBooleanExtra(ARG_SHOW_MESSAGES, false);
    if (showMessage)
    {
        clearNotification();
        super.loadUrl("file:///android_asset/www/de/index.html#messages");
    }
}

This works fine but it crashes sometimes with a NullPointerException – not on my mobile or emulator, but on other devices. The stacktrace says it is in the onNewIntent of the DroidGap activity, see Code:

protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    //Forward to plugins
    this.pluginManager.onNewIntent(intent);
}

I wasn’t able to reproduce this situation. Obviously pluginManager is null but I don’t why.

So the questions are:

  • Is the taken approach to select a specific page in jquery-mobile from Android good or can someone point out a better approach?
  • How can I get rid of the exception? Of course I could check pluginManager for beeing null and in this case don’t call super – but then my specific page isn’t activated.
  • Do you think this is a PhoneGap bug – not to check pluginmanager for null? When I checked the PhoneGap code I thought this should never happen, in my understanding onNewIntent is only called when the activity is loaded, otherwise onCreate would be triggered instead.

Update
I know more now: problem occurs when the app is not loaded and a C2DM message arrives.
The intent starts the app, the events occur in the following order – but onNewIntent is only called occasionally:

onCreate()
onNewIntent()
onResume()

Whenever onNewIntent is executed during the startup it crashes. Anyway I fixed this with:

@Override
protected void onNewIntent(final Intent intent)
{
    // avoid Phonegap bug
    if (pluginManager != null)
    {
        super.onNewIntent(intent);
    }
    setIntent(intent);
}

When I want to change the start page in the onResume-Event, this doesn’t work when Phonegap is not ready. So it is just to early to call the #messages page in onResume in the case that the application is starting. But when to call it then? Is there a possiblility to hook into onDeviceReady?

  • 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-05-30T11:49:57+00:00Added an answer on May 30, 2026 at 11:49 am

    I still do not know why sometimes onNewIntent is triggered during a application start (not just activated) and sometimes not. Anyway I solved all my problems with some workarounds.

    In my activity I created a new function (not relevant parts are stripped):

    public void onDeviceReady()
    {
        if (!isReady)
        {
            super.loadUrl("file:///android_asset/www/en/index.html#messages");
        }
    
        // activate onResume instead
        isReady = true;
    }
    

    and the boolean flag above:

    /** Is PhoneGap ready? */
    private boolean isReady = false;
    

    I activate the callback in the onCreate event:

    // Callback setzen
    appView.addJavascriptInterface(this, "Android");
    

    and call it from the Javascript onDeviceReady

    if (OSName == "Android")
    {
        window.Android.onDeviceReady();
    }
    

    In the onResume event I use the negotiated logic:

    protected void onResume()
    {
        super.onResume();
    
        if (isReady)
        {
            super.loadUrl("file:///android_asset/www/en/index.html#messages");
        }
    }
    

    This guarantees that the page selection is executed only once, either in onResume or in onDeviceReady.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an application with push notification alerts using Google C2DM service. Can
I am using Android-C2DM, and when I receive a message that has been pushed
I am developing android push notification application using C2DM,I am facing some problems in
i've implemented the c2dm on my phone application. The c2dm application does receive message
I am using C2DM application,I got registered in Google & the app is running
I'm using C2DM in my Application to send data from mobile to mobile But
I'am developing a sample push notification app in android using c2dm. Here is my
I am using android-c2dm, and my device successfully receives messages from it. I want
My app is using Google's C2DM (push notification) to notify users about new activity
I have developed push notification system in android using c2dm, It's working fine but

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.