Search code examples
androidbroadcastreceiverrecording

Why the Broadcast receiver does not work after killing Android app?


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.


Solution

  • 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.