ACTION_SHUTDOWN/QUICKBOOT_POWEROFF broadcast not working for Huawei devices

怎甘沉沦 提交于 2019-12-11 15:27:28

问题


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

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