问题
I am trying to get broadcast at device SHUTDOWN/Reboot in my app. I can get these events in Samsung and in OPPO devices but these are not working in Huawei devices. any guesses why?
this is my manifest file for broadcast receiver.
<receiver android:name=".broadcast_receivers.DeviceOnOffReceiver"
android:enabled="true">
<intent-filter android:priority="1">
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.intent.action.QUICKBOOT_POWEROFF" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWEROFF" />
<action android:name="android.intent.action.REBOOT"/>
</intent-filter>
</receiver>
and this is my code for Broadcast receiver
public class DeviceOnOffReceiver extends BroadcastReceiver {
private LoggerExtension loggerExtension = LoggerExtension.newInstance();
private static final String TAG = DeviceOnOffReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if(action != null) {
loggerExtension.w(TAG, "Action received:" + action);
} else {
loggerExtension.w(TAG, "No action found:"+action);
}
}
来源:https://stackoverflow.com/questions/58304798/action-shutdown-quickboot-poweroff-broadcast-not-working-for-huawei-devices