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

The Archive Base Latest Questions

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

I am really moving forward with my android application. I was able to implement

  • 0

I am really moving forward with my android application. I was able to implement onDestroy() and onPause() routines.

I have also managed to get Android’s notification service to place my icon with title and body in the notification bar/task menu.

The only problem with this notification service is that if my android app is already running, and has initiated the onPause() function that super.onPause(); moveTaskToBack(true);, if a users taps the notification, it will bring up a NEW instance of my app.

Once the user interacts with the new instance, the program will crash because the background version is already running, causing conflicts.

Here’s my notification code, I need help in making this code look for an already running version of my app:

String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificatonManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "app name";
long when = System.currentTimeMillis();
CharSequence contentTitle = "app title";
CharSequence contentText = "text";
Intent notificationIntent = new Intent(this, SuperMicProActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int signed = 1;
mNotificatonManager.notify(signed, notification);

I was looking at onResume() with may be some sort of bringTaskToFront(this) option. Does this exist?

Thanks,

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

    You have a few issues, IMHO.

    and has initiated the onPause() function that super.onPause(); moveTaskToBack(true);

    That is rather strange behavior. Why are you doing this?

    Once the user interacts with the new instance, the program will crash because the background version is already running, causing conflicts.

    Then whatever was being done in the original activity should not be in an activity at all, but in a service. Once you no longer have a foreground activity, the odds of Android terminating your process to free up memory is fairly high and may occur rather quickly, depending on what else is going on. You seem to be depending upon that older activity somehow still doing something. A “background version” of an activity should not be doing anything that would impact any other activity in your process, and an activity not in the foreground should not be responsible for doing anything that the user might miss if the activity goes “poof”.

    That being said, there are other reasons to avoid having a second copy of your activity, notably navigation — as it stands, when the user presses BACK from the second copy of the activity, they will see the first copy, and get confused.

    I need help in making this code look for an already running version of my app

    No, you “need help in making this code look for an already running version of” your activity. An app is not an activity. An activity is not an app.

    Adding FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_SINGLE_TOP to your Intent will solve this:

      Intent i=new Intent(this, SuperMicProActivity.class);
    
      i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
    
      PendingIntent pi=PendingIntent.getActivity(this, 0, i, 0);
    

    This will bring your existing activity to the foreground and, if needed, get rid of other activities in your task.

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

Sidebar

Related Questions

I'm moving from Java to C++ and have really enjoyed it. One thing I
Really ripping my hair out on this one. I have a JAAS Authentication Provider
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
Really simple question: From within GWT I want to forward the user away from
This is really a head scratcher for me. Essentially I have 3 MySQL tables
I have a JTable in a swing application. I wrote a quick and dirty
i m really very fed up coding translate animation. actually my image is moving
I'm moving a project to the new Android Native Development Kit (i.e. JNI) and
I really have no idea how to ask this, so with that have no
I really like the way ASP.NET MVC works. I'd love to implement it on

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.