BOOT COMPLETE is not working in Android (Redmi)

强颜欢笑 提交于 2019-11-28 12:54:43

This is solution for your bug.

What you need to do is that , you need to mention this permission also in your Intent-Filter.

               <receiver android:name="com.example.demoapp.MyReceiver"
                         android:enabled="true"
                         android:exported="true" >

               <intent-filter >
                       <action android:name="android.intent.action.BOOT_COMPLETED"/>
                       <action android:name="android.intent.action.REBOOT"/>
               </intent-filter>
               </receiver>

Here you need to do one thing also.

Go to "Settings-Apps_open your app info-Manage permisson" in yourdevice

Here check all things here.

Because for some devices it will not work. Ex.Red mi

Try this !

in case of XIOMI devices you have to manually set permission, i think you can solve this by adding your app in "auto-start management" list, which is available as default security app.

Go to manage app permission

Select your app from apps

toggle "Auto-Start"

done

try removing if condition from broadcast reciever

public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "Boot Complete.", Toast.LENGTH_LONG).show();
}
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!