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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:14:25+00:00 2026-06-17T05:14:25+00:00

I created a simple Status Notification that is launched via AlarmManager. Everything works fine

  • 0

I created a simple Status Notification that is launched via AlarmManager. Everything works fine (the content of the notification, the title, the activity being launched when it is tapped, etc.). Unfortunately, when the notification is called (ie, AlarmManager goes off), an empty activity is launched and displayed. The activity simply has the name of my app and its icon in the status bar. The actual activity itself is blank. Again, this happens when the notification goes off and appears in the status bar for the first time. When I tap on the notification again, it goes to the correct pending activity. Here’s my code:

Here’s the code that sets AlarmManager to call the Notification:

//Use AlarmManager to trigger the notification/alarm.
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); 

//PendingIntent to launch activity when the alarm triggers.                    
Intent intent = new Intent("com.YouForgotWhat.FlightGear.DisplayNotification");

PendingIntent displayIntent = PendingIntent.getActivity(getBaseContext(), 0, intent, 0);   

//Set an alarm to go off at 30 minutes before fuel runs out.
alarmManager.set(AlarmManager.RTC_WAKEUP, endTimeInMillis - (30*60*1000), displayIntent);

And here’s the actual code of the Notification itself (it’s in another Activity):

public class DisplayNotification extends SherlockActivity {
private Context context = this;

public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

    mBuilder.setContentTitle("Your fuel may be running low.")
            .setContentText("There are 30 mins left on your timer. Check your fuel gauges.")
            .setSmallIcon(R.drawable.ic_launcher);

    Intent intent = new Intent(this, FuelTimer.class);

    PendingIntent in = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
    mBuilder.setContentIntent(in);

    mNotificationManager.notify(0, mBuilder.build());

}

}

What do I do to fix this problem? 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-06-17T05:14:26+00:00Added an answer on June 17, 2026 at 5:14 am

    You’re launching an Activity to make the notification, it makes sense that at first you see an empty Activity – that’s exactly what you just launched. Use a BroadcastReceiver instead.

    So when it receives:

    public class Receiver extends BroadcastReceiver{
      @Override
      public void onReceive(Context context, Intent intent)
      {
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
    
        mBuilder.setContentTitle("Your fuel may be running low.")
          .setContentText("There are 30 mins left on your timer. Check your fuel gauges.")
          .setSmallIcon(R.drawable.ic_launcher);
    
        Intent intent = new Intent(context, FuelTimer.class);
    
        PendingIntent in = PendingIntent.getActivity(context, 0, intent, 0);
        mBuilder.setContentIntent(in);
    
        mNotificationManager.notify(0, mBuilder.build());
    
       } 
    }
    

    You will have to add the Receiver to the manifest:

    <receiver android:name="com.YouForgotWhat.FlightGear.Receiver" >
                <intent-filter>
                    <action android:name="com.YouForgotWhat.FlightGear.DisplayNotification" />
                </intent-filter>
     </receiver>
    

    Lastly, change you code to launch the receiver, so it is like

    //PendingIntent to launch activity when the alarm triggers.                    
    Intent intent = new Intent("com.YouForgotWhat.FlightGear.DisplayNotification");
    
    PendingIntent displayIntent = PendingIntent.getBroadcast(getBaseContext(), 0, intent, 0);   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple multicast player using actinscript 3 which works fine and
I have tried almost everything to link picture to Facebook status that is created
I've created a simple application with a single view controller and removed the status
A few years ago I created a simple app to track my daily status.
A while back, I created a simple Twitter status message reader in PHP. It
I want help with my UIScrollView sample. I created a simple program that scrolls
This is a pretty simple question, and it's blatantly my own newb status that's
I've created a simple Google analytics test site that has events (on the buttons)
I've created a simple function which allows me to determine which status options a
I created a simple test that opens a connection of sqlce located on my

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.