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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:26:38+00:00 2026-06-14T22:26:38+00:00

I am developing an application where the user may schedule training date and time.

  • 0

I am developing an application where the user may schedule training date and time. The user may schedule multiple training dates and times while using the application. Say for example the user will schedule two training, TR1 and TR2. When the TR1 date and time matches, a notification will be sent to the user and onclicking the notification the user will be directed to the Training Activity. The same will happen for TR2 on reaching the date and time of the training.

For scheduling the notifications, I am using the AlarmManager. The problem which I am facing is that, if I schedule multiple training, I am getting notified for only the last one.

The activity for generating the notifications:

public class SettingsActivity extends Activity {
    //objects for use
    DateFormat fmtDateAndTime=DateFormat.getDateTimeInstance();
      TextView dateAndTimeLabel;
      Calendar dateAndTime=Calendar.getInstance();
      ImageView confirm;
      String dateTime;

      EditText duration;

      //Alarm manager object for notification
      AlarmManager am;


      //notification date and time
      int hour;
      int minute;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings_portrait);
        duration=(EditText)findViewById(R.id.duration_editText);
        dateAndTimeLabel=(TextView)findViewById(R.id.timeTxt);

        updateLabel();
        updateNotification();
        am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

     // On Click Confirm

            confirm=(ImageView)findViewById(R.id.confirm_imageView);
            confirm.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    getDateTime();

                   setOneTimeAlarm();
                }
            });

      }
      //date picker
      public void chooseDate(View v) {
        new DatePickerDialog(SettingsActivity.this, d,
                              dateAndTime.get(Calendar.YEAR),
                              dateAndTime.get(Calendar.MONTH),
                              dateAndTime.get(Calendar.DAY_OF_MONTH))
          .show();
      }
      //time picker
      public void chooseTime(View v) {
        new TimePickerDialog(SettingsActivity.this, t,
                              dateAndTime.get(Calendar.HOUR_OF_DAY),
                              dateAndTime.get(Calendar.MINUTE),
                              true)
          .show();
      }

      private void updateLabel() {
        dateAndTimeLabel.setText(fmtDateAndTime
                                  .format(dateAndTime.getTime()));
      }

      DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() {
        public void onDateSet(DatePicker view, int year, int monthOfYear,
                              int dayOfMonth) {
          dateAndTime.set(Calendar.YEAR, year);
          dateAndTime.set(Calendar.MONTH, monthOfYear);
          dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
          updateLabel();
          updateNotification();
        }
      };

      TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() {
        public void onTimeSet(TimePicker view, int hourOfDay,
                              int minute) {
          dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
          dateAndTime.set(Calendar.MINUTE, minute);
          updateLabel();
          updateNotification();

        }
      };  




   // Notification Function
//      private void Notification(String notificationTitle, String notificationMessage)
//      {
//          NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
//          Notification notification = new Notification(R.drawable.ic_launcher, "Training Scheduled!", System.currentTimeMillis());
//          //on click notification goto dinnerden activity
//          Intent notificationIntent = new Intent(this, SettingsActivity.class);
//          PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
//   
//          notification.setLatestEventInfo(SettingsActivity.this, notificationTitle, notificationMessage, pendingIntent);
//          notificationManager.notify(10001, notification);
//      }
      //getting date time from textview
      void getDateTime()
      {
         dateTime= dateAndTimeLabel.getText().toString()+" Duration HRS: "+duration.getText().toString();

         makeAToast(dateTime);
         //Notification("Training Scheduled at:",dateTime);

      }

      void updateNotification()
      {
          hour= dateAndTime.get(Calendar.HOUR_OF_DAY);
          minute=dateAndTime.get(Calendar.MINUTE);
      }



      public void setOneTimeAlarm() {

        // the time set
         Calendar calendar = Calendar.getInstance();
//          hour= dateAndTime.get(Calendar.HOUR_OF_DAY);
//          minute=dateAndTime.get(Calendar.MINUTE);
        // int hour= dateAndTime.get(Calendar.HOUR_OF_DAY);
        // int minute=dateAndTime.get(Calendar.MINUTE);
         // noon tomorrow
         //calendar.add(Calendar.DAY_OF_YEAR, 1);
         calendar.set(Calendar.HOUR_OF_DAY, hour);
         calendar.set(Calendar.MINUTE, minute);
         calendar.set(Calendar.SECOND, 0);





      Intent intent = new Intent(this, TimeAlarm.class);
      PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
        intent, PendingIntent.FLAG_ONE_SHOT);
      am.set(AlarmManager.RTC_WAKEUP,
       calendar.getTimeInMillis(), pendingIntent);
     }

     public void setRepeatingAlarm() {
      Intent intent = new Intent(this, TimeAlarm.class);
      PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
        intent, PendingIntent.FLAG_CANCEL_CURRENT);
      am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
        (5 * 1000), pendingIntent);
     }








      public void makeAToast(String str) {

        Toast toast = Toast.makeText(this,str, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.setDuration(1000000);
        toast.show();
    }
}

The class for creating the notifications:

public class TimeAlarm extends BroadcastReceiver {

     NotificationManager nm;

     @Override
     public void onReceive(Context context, Intent intent) {
      nm = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
      CharSequence from = "Scheduled Training";
      CharSequence message = "Please attend the scheduled training";
     // Intent welcomeIntent = new Intent(context, CustomAlarm.class);
      PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
        new Intent(), 0);
      Notification notif = new Notification(R.drawable.ic_launcher,
        "Crazy About Android...", System.currentTimeMillis());
      notif.setLatestEventInfo(context, from, message, contentIntent);
      nm.notify(1, notif);
     }
    }

The layout for the activity:

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="488dp" >

            <ImageView
                android:id="@+id/confirm_imageView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:src="@drawable/schedule_button" />

            <TextView
                android:id="@+id/timeTxt"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_marginTop="41dp"
                android:text="@string/time_show" />

            <Button
                android:id="@+id/timeBtn"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/timeTxt"
                android:layout_marginTop="34dp"
                android:onClick="chooseTime"
                android:text="@string/time" />

            <Button
                android:id="@+id/dateBtn"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/timeBtn"
                android:layout_marginTop="38dp"
                android:onClick="chooseDate"
                android:text="@string/date" />

            <EditText
                android:id="@+id/duration_editText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/dateBtn"
                android:layout_marginTop="36dp"
                android:ems="10"
                android:hint="@string/duration_hint"
                android:inputType="number" />

            <TextView
                android:id="@+id/duration_textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/duration_editText"
                android:layout_alignBottom="@+id/duration_editText"
                android:layout_alignParentLeft="true"
                android:text="@string/duration"
                android:textAppearance="?android:attr/textAppearanceMedium" />

        </RelativeLayout>

    </LinearLayout>
    </ScrollView>

Part of manifest.xml:

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <receiver android:name="com.project.nuroq.android.app.TimeAlarm" />

I want to fire the notifications at particular time(implemented) and dates(yet to implement) which is not happening now. The last is only getting fired!

Where am I going wrong? Thanks in advance!

  • 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-14T22:26:40+00:00Added an answer on June 14, 2026 at 10:26 pm

    You have to use different ID for each notification. If, as you do, all would use the same ID value, then, according to notify() docs, previous one gets replaced with new one:

    Post a notification to be shown in the status bar. If a notification
    with the same id has already been posted by your application and has
    not yet been canceled, it will be replaced by the updated information.

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

Sidebar

Related Questions

I am developing an application which requires real-time updates to the end user. However,
I'm developing an application (user space) which send notifications of value changes via network.
I'm developing an application in .NET where the user can provide Regular Expressions that
I am developing an application that allows for a user to manage some individual
I am developing a web application with which user can view files in the
I'm developing an application that tracks the user's current position and stores it into
I am developing an application that uses the SKPSMTPMessage to send the forgotten user
I'm developing an application that needs to perform some processing on the user's Outlook
I am developing an application and I'd like to offer the user a possibility
I’m developing an application dedicated to generate statistical reports, I would like that user

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.