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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:45:51+00:00 2026-06-11T06:45:51+00:00

I have an Android application that allows a user to add an alarm that

  • 0

I have an Android application that allows a user to add an alarm that will log their location. For example, every day at 8am I want to log where I am. When the alarm is received, it starts a service that gets the user’s location and saves it to a db. The feature works fine when the app is running (in the background or foreground).

The problem is, the alarm doesn’t seem to go off if I go into the task manager and force the app to close. This is important as the user could reboot their phone and kill the app.

Here is the method that sets the alarm:

private void setNewAlarm(int hour, int minute, int id) {
    Intent alarmIntent = new Intent(AutoLoggerActivity.this, AlarmReciever.class);
    alarmIntent.putExtra(Constants.ALARMID_FIELD_NAME, id);
    PendingIntent sender = PendingIntent.getBroadcast(AutoLoggerActivity.this, id, alarmIntent, 0);

    Calendar alarmCal = Calendar.getInstance();
    alarmCal.set(Calendar.HOUR_OF_DAY, hour); // set user selection
    alarmCal.set(Calendar.MINUTE, minute); // set user selection
    alarmCal.set(Calendar.SECOND, 0);

    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarmCal.getTimeInMillis(), 120000, sender);
}

Here is the BroadcastReceiver:

public class AlarmReciever extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle bundle = intent.getExtras();     
        int alarmId = bundle.getInt(Constants.ALARMID_FIELD_NAME);
        Toast.makeText(context, "Alarm Running: ID = " + alarmId, Toast.LENGTH_LONG).show();
        Log.d(TAG, "AlarmReceiver: onRecieve. ID = " + alarmId);

        Intent serviceIntent = new Intent(context, LocationRecordingService.class);
        serviceIntent.putExtra(Constants.ALARMID_FIELD_NAME, alarmId);
        context.startService(serviceIntent);
    }
}

Any idea why this is happening?

  • 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-11T06:45:53+00:00Added an answer on June 11, 2026 at 6:45 am

    This is actually a design feature of the Android operating system, and isn’t something you can cirumvent. An application that is in a “stopped” state cannot receive any broadcasts. It is only in this state under two conditions:

    1. When the application is first installed before it is ever launched
    2. When the user actively goes into Settings and does a force close

    The problem is, the alarm doesn’t seem to go off if I go into the task manager and force the app to close. This is important as the user could reboot their phone and kill the app.

    This is not quite true, because if the device is rebooted the application is not considered to be in this state of being “stopped”. However, alarms do not persist reboots, so your application will need to listen for ACTION_BOOT_COMPLETED broadcast by the system when the device starts up so you can reschedule any pending alarms.

    If the user actively kills your app, you must respect that choice of theirs.

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

Sidebar

Related Questions

I have a drawing application in Android that allows the user to draw with
I have recently created an Android application that allows users to add shopping items
I have an Android application that allows the user to connect to his Facebook
I'm new to Android development. I have an application that allows the user to
I have an android application that displays a toast every hour and then every
So in my application, I have a seekbar that allows the user to set
I have an android application which allows the user to take a picture using
I'm writing an application in Android that will allow a user to register for
I have an android application that launches a child Activity under certain situations. Both
I have an Android application that connects to Facebook to request authorization of an

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.