android 9.0接收静态广播
16lz
2021-01-24
android8.0以后的系统,为了提高系统的性能,所以对第三方app注册的静态广播,不做处理,该怎么解决这问题呢,下面直接分享代码:
Intent poweronff = new Intent("com.bob.intent.action.POWER_ON_OFF_TIMER");//自定义action poweronff.putExtra("enable",true); poweronff.putExtra("timeon",poweron); poweronff.putExtra("timeoff",poweroff);poweronff.setComponent(new ComponentName("com.android.tv.settings.receiver","com.android.tv.settings.receiver.PoweronoffBroadcastReceiver"));//第一个参数包名,第二个参数广播类 mContext.sendBroadcast(poweronff);
2.注册广播类
<receiver android:name=".PoweronoffBroadcastReceiver" android:exported="true"> <intent-filter android:priority="1000"> <action android:name="com.bob.intent.action.POWER_ON_OFF_TIMER"/> </intent-filter> </receiver>
更多相关文章
- android调用系统拍照程序和从图库选取图片,返回后调用系统裁剪工
- 转载:android 源码 打包成apk的实现
- android8.1 系统应用使用FileProvider时提示没有权限
- 存储容量检测 注意构建StatFs对象的参数合法性
- 基于32bit系统编译Android(安卓)2.3
- Android(安卓)activity 参数传递
- Android(安卓)的系统属性(SystemProperties)设置分析
- Android(安卓)使用xliff 格式化字符串
- MUI移动开发框架——微信支付(android部分)