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

南楼画角 提交于 2019-12-12 13:44:34

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/44389854/why-the-broadcast-receiver-does-not-work-after-killing-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!