Broadcast Receiver Not Working When App Is Cleared From Ram
Solution 1:
In Xiaomi devices, you just have to add your app to Autostart list, to do so, follow these simple steps given below:
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:
- Make sure that you are scheduling your alarm correctly.
- Make sure that you are setting the propers permissions on the manifest.
- 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"