Skip to content Skip to sidebar Skip to footer

Broadcast Receiver Not Working When App Is Cleared From Ram

I am new to android. I am making an alarm clock. Its working perfectly until the user clears the app from the RAM. On searching, I found that broadcast receivers don't work if the

Solution 1:

In Xiaomi devices, you just have to add your app to Autostart list, to do so, follow these simple steps given below:

  • Open Security app on your phone.

  • Tap on Permissions, it'll show you two options: Autostart and Permissions

  • Tap on Autostart, it'll show you list of apps with on or off toggle buttons.

  • Turn on toggle of your app, you're done!

Solution 2:

You can register broadcast receivers either inside the activity at runtime or in the manifest. You want to adopt the latter approach

Solution 3:

In the past I have similar problems with AlarmManager, AlarmReceivers and this kind of things. There are some tips that can help you in your code:

  1. Make sure that you are scheduling your alarm correctly.
  2. Make sure that you are setting the propers permissions on the manifest.
  3. Take care if the device is locked or it was rebooted.

There is a quite useful tutorial that helps me to control and make a "Hello World!" example with AlarmManager: AlarmManager Repeating Example

Note: In API 19 and higher, the method setRepeating is not exactly (maybe the alarm triggers at 10:00 or at 10:15), so you must use setExact.

Hope it helps!

Solution 4:

You can register broadcast receiver in two ways

1. From your activity.

2. From your manifest.

if you registered broadcast throught activity, It wont receive after your activity is destroyed, So thats is where we register BroadcastReceiver in manifest.

This link will help you BroadcastReceiver

Post a Comment for "Broadcast Receiver Not Working When App Is Cleared From Ram"