为什么广播接收器在杀死Android应用后无法正常工作?

问题描述:

我正在使用我的应用程序中的广播接收器来记录通话。在Android 5.0模拟器设备上一切正常。如果我取消了该应用程序,它将自动开始记录通话。但是,当我在运行Android 6.0的设备上安装该应用程序时,该应用程序将一直运行,直到该应用程序运行为止。当我终止该应用程序时,录制未开始,广播接收器也未触发。

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.

字符串制造商= xiaomi;

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.