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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:05:09+00:00 2026-05-28T03:05:09+00:00

In my app, i am setting the Notification as like below code: // for

  • 0

In my app, i am setting the Notification as like below code:

    // for the PAYE 18 APRIL 2011 // 1  
    AM_EM_APRIL_2011 = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    Intent in1 = new Intent(this, AlarmReceiverNotificationForEveryMonth.class);
    in1.putExtra("MyMessage","Your PAYE return is DUE on 20th April 2011.");
    PI_EM_APRIL_2011 = PendingIntent.getBroadcast(this, 1, in1, PendingIntent.FLAG_UPDATE_CURRENT);
    Calendar calendar_PAYE_18_APRIL_2011 = Calendar.getInstance();
    calendar_PAYE_18_APRIL_2011.setTimeInMillis(System.currentTimeMillis());
    calendar_PAYE_18_APRIL_2011.set(2011, 3, 18,mHour, mMinute, 0);
    AM_EM_APRIL_2011.set(AlarmManager.RTC_WAKEUP, calendar_PAYE_18_APRIL_2011.getTimeInMillis(),PI_EM_APRIL_2011);

Broadcast class for notification is:

public class AlarmReceiverNotificationForTwoMonth extends BroadcastReceiver{
//private Intent intent;
private NotificationManager notificationManager;
private Notification notification;
public static CharSequence contentText;
@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub

    // My Notification Code
    notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.app_icon;
    //System.out.println("The ID Number is: "+Long.parseLong(intent.getData().getSchemeSpecificPart()) );
    contentText = intent.getStringExtra("MyMessage");
    System.out.println("The Message is: "+intent.getStringExtra("MyMessage"));
    CharSequence text = "Your tax amount due period";
    CharSequence contentTitle = "Tax Calculator App";

    long when = System.currentTimeMillis();

    intent = new Intent(context, MenuPageActivity.class);
    intent.putExtra("twoMonth", "twoMonth");
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    notification = new Notification(icon,text,when);

    long[] vibrate = {0,100,200,300};
    notification.vibrate = vibrate;  // To vibrate the Device

    notification.ledARGB = Color.RED;
    notification.ledOffMS = 300;
    notification.ledOnMS = 300;

    notification.defaults |= Notification.DEFAULT_LIGHTS;
    //notification.flags |= Notification.FLAG_SHOW_LIGHTS;

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    notificationManager.notify(NotificationConstants.NOTIFICATION_ID_TWO_MONTH, notification);
}

}

All Works good with this code. and i got the Notification. But using this i got notification everytime when ever i restart the device. and there are no any message in that notification. Why it is happend like this???
Please help me for this. or what wrong in my code ???

Thanks.
Edited

I have done like this in manifest.xml

<!-- To receive the Alarm Notification for two months-->
    <receiver android:name=".AlarmReceiverNotificationForTwoMonth" android:enabled="true">  
         <intent-filter>                 
            <action android:name="android.intent.action.BOOT_COMPLETED"/>                 
            <category android:name="android.intent.category.DEFAULT"/>             
         </intent-filter>   
    </receiver>  
  • 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-28T03:05:10+00:00Added an answer on May 28, 2026 at 3:05 am

    Is your AlarmReceiverNotificationForTwoMonth class specified in your manifest as the receiver of the BOOT_COMPLETED broadcast?

    If so, then the AlarmReceiverNotifictionForTwoMonth.onReceive() method will be triggered every time the device has booted, and as a result show a notification.

    EDIT: Your approach with using the AlarmManager is good. The only problem is that alarms are not restored when the device is rebooted. Therefore you need to recreate any existing alarm when the device reboots. My suggestion would be to change your manifest to this:

        <receiver android:name=".AlarmReceiverNotificationForTwoMonth" android:enabled="true" >
        </receiver>
        <receiver android:name=".RecreateAlarms" >
            <intent-filter >
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
    

    Then create a new class

    public class RecreateAlarms extends BroadcastReceiver {
    
    @Override
    public void onReceive(Context context, Intent intent) {
    
        // reschedule alarms here
    }
    

    I don’t know your logic when an alarm should be triggered. You may need to save an alarm to a file/database in your AlarmReceiverNotificationForTwoMonth method and read it in the RescheduleAlarms to know if there are any alarms to recreate

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

Sidebar

Related Questions

I'd like to allow user to change the setting of app. But I am
In iOS5, the default setting for an app notification is Banners . Is there
I have used the following code to register my app to receive push notification,
After receiving push notification app icon not display badge. In setting notification is on,
Is it possible to pass a App setting string in the web.config to a
I am setting up a rails app and I just finished making some unit
I'm setting out to create an app where it will use 7-10 instances of
If I have the following setting in my app.config file. It is a setting
I am having trouble setting the path to jquery in an mvc app. In
I need to read a setting from the appsettings section (defined in app.config) in

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.