I am testing a very basic app for getting Boot_Completed
broadcast on device reboot. I am testing app on android 10 OPPO device
Following is my code
Manifest.xml
<receiver android:name=".SampleBootReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<!--For HTC devices-->
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
SampleBootReceiver.java
public class SampleBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("MyApp", " Boot completed fired");
Toast.makeText(context, "fired " , Toast.LENGTH_LONG).show();
if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED")){
Log.e("MyApp", "matches intent");
}
}
}
My application didn't receiving Boot_Completed
broadcast on device reboot.
NOTE - If i start the app manually just after device reboot, then i am getting broadcast in my app and able to see logs in logcat. But when i didn't start app after device reboot, nothing print in logcat.
I even tried putting showing toast
on receiving broadcast, nothing happens.
Please suggest !