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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:09:40+00:00 2026-05-19T09:09:40+00:00

I currently have an app which, when a button is pressed, and after a

  • 0

I currently have an app which, when a button is pressed, and after a certain period of time, a statusbar notification is set.

Everything works fine apart from the fact if the user does not have the application open, when the notification appears, the app also reopens. This is not what i would like to happen. I would like the notification to appear on it’s own (wherever the user is).

On my button press i use:

    // get a Calendar object with current time
Calendar cal = Calendar.getInstance();
// add minutes to the calendar object
cal.add(Calendar.SECOND, time);
Intent alarmintent = new Intent(getApplicationContext(), AlarmReceiver.class);
alarmintent.putExtras(bundle);
// In reality, you would want to have a static variable for the request code instead of 192837
PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), HELLO_ID, alarmintent, 0);
// Get the AlarmManager service
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);

This calls my AlarmReceiver.class, which uses this code to call my notification class:

        Intent myIntent = new Intent(context, Note.class);
    myIntent.putExtras(bundle2);


     myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);

    context.startActivity(myIntent);

notification.class:

public class Note extends Activity {




    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String ns = Context.NOTIFICATION_SERVICE;
        final NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

        int icon = R.drawable.launcher;
        CharSequence tickerText = "Remind Me!";
        long when = System.currentTimeMillis();

        final Notification notification = new Notification(icon, tickerText, when);

    notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_NO_CLEAR;

    final Context context = getApplicationContext();
    CharSequence contentTitle = "Remind Me!";
    CharSequence contentText = param1;

    Intent notificationIntent = new Intent(context, Completed.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);


            mNotificationManager.notify(HELLO_ID, notification);

            HELLO_ID++;


         }
}
  • 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-19T09:09:41+00:00Added an answer on May 19, 2026 at 9:09 am

    This is the expected result, as the Intent you create in your AlarmReceiver class explicitly launches your Note Activity.

    Why not simply create the Notification in your AlarmReceiver? (rather than launching your activity)

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

Sidebar

Related Questions

I have a very large app, 1.5 million lines of C++, which is currently
I have a small iPhone app which has a button on the first view.
I am currently making an app which works with images. I need to implement
I have a requirement on my current project (a Flex app which will be
I have an internal enterprise app that currently consumes 10 different web services. They're
I have an Open Source app and I currently only post the binary for
I have a search form in an app I'm currently developing, and I would
We are currently storing plain text passwords for a web app that we have.
I have an app that display's the current time when a page opens. I
I currently have speakers set up both in my office and in my living

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.