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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:17:22+00:00 2026-05-24T22:17:22+00:00

My app has a notification service. The problem is when my app has been

  • 0

My app has a notification service. The problem is when my app has been minimised [by pressing the home button] and notification service fires a notification my main activity gets started on its own. Its really annoying and i need to fix it.

Any one with a probable solution??

I tried using android:launchMode=”singleInstance” given as a solution @ Why does starting an activity from a widget cause my main activity to start as well? but the problem with this solution is that if i try to re-start my app using the “long press home button, which gives the list of recently used app” my app never runs.

In order to re-run it then i have to go to my App’s Icon in menu and open it from there.

Is there a way i can solve both these problems??

Activity that generates notification :

package org.example.com;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;

public class ParentActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_copy);

    NotificationManager newNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    final Notification notificationDetails = new Notification(R.drawable.icon,"Downloads available!!",System.currentTimeMillis());
    notificationDetails.flags = Notification.FLAG_AUTO_CANCEL;

    Intent newIntent = new Intent(this,ParentActivity.class);
    newIntent.putExtra("IS_FOREGROUND",1);
    //newIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent newPendingIntent = PendingIntent.getActivity(this, 0, newIntent, 0);

    CharSequence contentTitle = "Downloads Available!!";
    CharSequence contentText  = "Some new Downloads are available, click to enable.";
    int notificationId = 3;

    notificationDetails.setLatestEventInfo(this, contentTitle, contentText, newPendingIntent);
    newNotificationManager.notify(notificationId, notificationDetails);

    finish();

}
}
  • 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-24T22:17:24+00:00Added an answer on May 24, 2026 at 10:17 pm

    I see in your code that your are in an activity, that’s why your application come to the foreground I think. Does your service start this activity?
    If it is a service that fires the notification, why not creating the notification in that service? Then your application will stay in the background.

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

Sidebar

Related Questions

Is there a way to get a system notification when an app has been
Is there a way to send a notification to the user that app has
I had created an App Id and enabled Push notification service in clients's apple
I have the following problem, related to the Apple Push Notification service on iPhone:
I'd like to implement a push notification service in my iPad app. But before
My app has many controls on its surface, and more are added dynamically at
My app has a DataGridView object and a List of type MousePos. MousePos is
My app has several buttons which trigger different events. The user should NOT be
My app has a session timeout after 30 minutes. If the user has a
My app has three text fields: 1) Username // Initialization code usernameTextField = [[UITextField

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.