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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:42:29+00:00 2026-05-27T08:42:29+00:00

I am using AlarmManager and NotificationManager with BroadcastReceiver . When I set an alarm

  • 0

I am using AlarmManager and NotificationManager with BroadcastReceiver.
When I set an alarm with a specific date, it is working the first time. However, when I modify the date and click the confirm button, the alarm is working any date
immediately. I want to set the alarm interval day after expired date with fixed time.
What is the problem with it? I don’t understand at the moment.

confirmButton.setOnClickListener(new View.OnClickListener() 
{
    public void onClick(View v) {
    //set alarm with expiration date                
    am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    setOneTimeAlarm();
    Toast.makeText(fridgeDetails.this, "Alarm automatic set", 
        Toast.LENGTH_SHORT).show();
    setResult(RESULT_OK);
    finish();
}

public void setOneTimeAlarm() {
    c.set(Calendar.HOUR_OF_DAY, 14);
    c.set(Calendar.MINUTE, 49);
    c.set(expiredYear, expiredMonth, expiredDay);
    Intent myIntent = new Intent(fridgeDetails.this, AlarmService.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(
        fridgeDetails.this, 0, myIntent, PendingIntent.FLAG_ONE_SHOT);
    am.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(),
        AlarmManager.INTERVAL_DAY, pendingIntent);
}
}); 

AlarmService.java

public class AlarmService extends BroadcastReceiver{
    NotificationManager nm;
    @Override
    public void onReceive(Context context, Intent intent) {
        nm = (NotificationManager) context.getSystemService(
            Context.NOTIFICATION_SERVICE);
        CharSequence from = "Check your fridge";
        CharSequence message = "It's time to eat!";
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
            new Intent(), 0);
        Notification notif = new Notification(R.drawable.ic_launcher,
            "Keep Fridge", System.currentTimeMillis());
        notif.setLatestEventInfo(context, from, message, contentIntent);
        notif.defaults |= Notification.DEFAULT_SOUND; 
        notif.flags |= Notification.FLAG_AUTO_CANCEL; 
        nm.notify(1, notif);
    }   
}
  • 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-27T08:42:29+00:00Added an answer on May 27, 2026 at 8:42 am

    You need to set the property instead of FLAG_ONE_SHOT. This is for single alarm event not for the repeat. try this

    PendingIntent pendingIntent = PendingIntent.getBroadcast(
            fridgeDetails.this, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    

    see more detail about from here

    Edit:

    As you do for notification with PendingIntent

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

    In this you pass the empty object of Intent you need to pass the class name for that when you click on notification which Activity will be launch like in Alarm set time you do

    Intent myIntent = new Intent(fridgeDetails.this, AlarmService.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(
            fridgeDetails.this, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    

    now just pass the Acitivity name in the intent like suppose you want to launch your home activity and activity name like “homeactivity”

    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(context,HomeActivity.class), 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to set Alarm Tone from My Application using AlarmManager? My RingTonePicker Method:- private
I am setting an alarm using an AlarmManager. The AlarmManager is set with the
I start a service using alarm manager using button click. It is working too.
I'm trying to create my first AppWidget using the AlarmManager class so that I
I try to use alarm manager to run alarm at specific time every day.
I decided to write simple alarm clock (using AlarmManager). When alarm works out I
I have created a Alarm using AlarmManager. Intent intent = new Intent(MyApp.this,NotificationMessage.class); PendingIntent sender
I have an application, which sets an alarm using AlarmManager, which starts another Activity
I'm doing one application like raising email intent by time using AlarmManager . In
I am using the alarmManager to set up multiple alarms within my application and

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.