I am using a broadcast receiver in my app to record calls. Everything works fine in Android 5.0 emulator device. If I kill the app, it automatically starts recording calls. But the same app when I installed on my device running Android 6.0, it works until the app is running. When I kill the app the recording is not started, the broadcast receiver is not triggered.
Asked
Active
Viewed 799 times
3
-
What is the 6.0 device. On some devices swiping off the app does not kills it but force stops it. Which wont trigger the receiver – X3Btel Jun 06 '17 at 12:21
-
Android 6.0 Marshmallow device. – Paras Watts Jun 06 '17 at 12:22
-
Is it by any chance Xiaomi or OPPO – X3Btel Jun 06 '17 at 12:24
-
What is the solution to this? So that it does not force closes the receiver – Paras Watts Jun 06 '17 at 12:24
-
Yes Xiaomi Redmi note 4 – Paras Watts Jun 06 '17 at 12:25
-
I am also using a broadcast receiver to check network, that receiver is working fine, this receiver is also working fine in emulator – Paras Watts Jun 06 '17 at 12:26
-
On Xiaomi devices swiping the app executes 'Force stop' on force stop the receiver wont work, im not sure there is anything you can do. This will happen on XIaomi`s MIUI and some other custom ROM – X3Btel Jun 06 '17 at 12:29
-
Yes I just checked another thread that has discussed this problem, I am giving link you can also check that https://stackoverflow.com/questions/41506105/sms-broadcastreceiver-doesnt-receive-sms-after-app-killed-or-device-restart-on – Paras Watts Jun 06 '17 at 12:30
-
My question may sound dumb but are you registering your broadcast receiver in the manifest ? – A.Edwar Jun 06 '17 at 12:35
-
Yes , in manifest – Paras Watts Jun 06 '17 at 12:36
-
Please accept your answer. This will help others and also get the question off the list of unanswered questions. – David Wasser Jun 06 '17 at 13:14
-
1It say I can accept my own answer in 2 days – Paras Watts Jun 06 '17 at 13:53
-
I think your questions could look *much* better with only a little [improvement](https://meta.stackoverflow.com/a/291370/1783163). – peterh Jun 07 '17 at 17:52
1 Answers
3
String manufacturer = "xiaomi";
if(manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
//this will open auto start screen where user can enable
permission for your app
Intent intent = new Intent();
intent.setComponent(new
ComponentName("com.miui.securitycenter",
"com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(intent);
}
I used this code and now its working fine.

Paras Watts
- 2,565
- 4
- 21
- 46