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>

更多相关文章

  1. android调用系统拍照程序和从图库选取图片,返回后调用系统裁剪工
  2. 转载:android 源码 打包成apk的实现
  3. android8.1 系统应用使用FileProvider时提示没有权限
  4. 存储容量检测 注意构建StatFs对象的参数合法性
  5. 基于32bit系统编译Android(安卓)2.3
  6. Android(安卓)activity 参数传递
  7. Android(安卓)的系统属性(SystemProperties)设置分析
  8. Android(安卓)使用xliff 格式化字符串
  9. MUI移动开发框架——微信支付(android部分)

随机推荐

  1. Android(安卓)Spinner 使用初步
  2. Android(安卓)HAL技术详解
  3. 解决了在Android原生TextView中,当text长
  4. Eclipse 点击 Run 自动生成 out 文件的错
  5. Android定时器AlarmManager和Timer的区别
  6. Dialog使用findViewById 报空指针异常
  7. 浅析Android中build.gradle的实用技巧
  8. ImageView宽度填满屏幕,高度自适应
  9. Android(安卓)中文API (68) ―― Bluetooth
  10. Android入门开发之SD卡读写操作