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

  • Home
  • SEARCH
  • 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 7719771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:29:58+00:00 2026-06-01T03:29:58+00:00

I have the Activity running in singleTop mode and C2DM receiver. On some notification

  • 0

I have the Activity running in singleTop mode and C2DM receiver. On some notification I need to run that activity and I doing it in that way:

Intent activity = new Intent(context, klass);
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(activity);

When activity if background (e.g. Home button pressed before), everything works fine.
But when I just pressed Power button to switch off screen, running activity cannot be notified about some changes (onNewIntent never called).

How can I notify running activity about notification?

  • 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-01T03:29:59+00:00Added an answer on June 1, 2026 at 3:29 am

    Skayred,
    I believe I had the exact same situation. However I noticed when the phone was asleep and a new intent was sent to the activity it would not start the activity until the screen was on(For my purposes I wanted the screen on).

    My solution was to acquire a wakelock in my C2DM receiver.

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,     TAG);
    mWakeLock.acquire();
    

    Of course, be sure to release the lock with mWakeLock.release() in your Activity.

    This is strange behavior and it does not seem is consistent with other android activity behavior. In my case I am using a singleTask activity(I’m not sure what type of activity your using, you did not state). If there is not an instance of the activity at the top of the stack, and the phone is asleep my activity will start and I can use the following in the onCreate():

    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 
    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    

    However if the activity is on the top of the stack and the phone is asleep the activity is not started until I turn the screen on. Hopefully this works for you. If you don’t need the screen to come on I would try playing with the other flags for the wakelock.

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

Sidebar

Related Questions

I have an activity that is triggered by a notification (when the user clicks).
I have an Android app, in which Activities fire long running operations that run
I have an Activity that starts a Service. In my Activity: startService(new Intent(this, MyService.class));
I have an activity that gets some data from the internet in background while
I have a long running activity (where the activity is continually doing work for
I have an activity that essentially launches a CountDownTimer. I need this to continue
I have a list activity which display all running applications in the device. it's
I have Activity A with android:launchMode=singleTop in the manifest. If I go to Activity
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have an activity which shows some List entries. When I click on a

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.