In XiaoMi 2A, Android Version 4.1, I cann't receive any broadcast after reboot unless I launch my app. XiaoMi disabled boot completed broadcast for apps in default unless users open it. I have read a lot of posts here:
Broadcast receiver not working in ICS if the app is not started atleast once
http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html
Cannot receive broadcast in ICS
They all said google just made it happen after Android version 3.0. The truth is with my Galaxy Nexus of Android 4.3, the custom broadcast(not boot completed) can be received even app is not launched before after reboot. Even with XiaoMi System, broadcast can be received after I open boot completed permission for my app. Can someone tell me why?
Here is the sending Intent:
Intent intent = new Intent();
intent.setAction("com.test.test");
intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | intent.getFlags());
context.sendBroadcast(intent);
and the receive is below:
<receiver
android:name="com.test.TestReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.test.test"></action>
</intent-filter>
</receiver>
public class TestReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("com.test.test")) {
Log.e("Chris", "received test action");
}
}
}