当前位置: 首页 > news >正文

大理中小企业网站建设搜索引擎在哪里获取网站

大理中小企业网站建设,搜索引擎在哪里获取网站,手机中国第一手机门户,wordpress 双域名前言 最近有项目过程中#xff0c;有做app的同事反馈#xff0c;三方应用无法监听关机广播。特地研究了下关机广播为啥监听不到。 1.原因#xff1a;发送关机广播的类是ShutdownThread.java#xff0c;添加了flag:Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER…前言 最近有项目过程中有做app的同事反馈三方应用无法监听关机广播。特地研究了下关机广播为啥监听不到。 1.原因发送关机广播的类是ShutdownThread.java添加了flag:Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER_REGISTERED_ONLY,表示只有在代码中动态注册并且是前台服务和应用才能收到所以在AndroidManifest.xml注册无法收到关机广播后台服务中动态注册也无法收到。 2.前台服务注册关机广播。 1.启动前台服务  public class BootCompleteReceiver extends BroadcastReceiver {private static final String TAG BootCompleteReceiver;Overridepublic void onReceive(Context context, Intent intent) {if (intent ! null) {if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { // ComponentName powerService new ComponentName(com.android.mytest, com.android.mytest.PowerService); // Intent mIntent new Intent(); // mIntent.setComponent(powerService);Intent powerServiceIntent new Intent(context, PowerService.class);context.startForegroundService(powerServiceIntent);Log.d(TAG, startForegroundService);}}} } 2、添加前台服务权限配置相关属性 权限 uses-permission android:nameandroid.permission.RECEIVE_BOOT_COMPLETED /uses-permission android:nameandroid.permission.INTERNET /uses-permission android:nameandroid.permission.FOREGROUND_SERVICE / 服务配置: serviceandroid:name.PowerServiceandroid:foregroundServiceTypemediaPlaybackandroid:enabledtrueandroid:exportedfalse intent-filteraction android:namecom.gwm.car.PowerService//intent-filter/service 3.注册关机广播 package com.android.mytest;import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.IBinder; import android.util.Log;import androidx.annotation.Nullable;public class PowerService extends Service {private static final String TAG PowerService;public ShutdownBroadcastReceiver mShutdownBroadcastReceiver;Overridepublic void onCreate() {super.onCreate();Log.d(TAG, onCreate);mShutdownBroadcastReceiver new ShutdownBroadcastReceiver();}private Notification getNotification() {NotificationChannel channel new NotificationChannel(channel_id, channel_name, NotificationManager.IMPORTANCE_DEFAULT);NotificationManager manager (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);if (manager ! null) {manager.createNotificationChannel(channel);}return new Notification.Builder(this, channel_id).setContentTitle(shutdown).setContentText(Listening for shutdown) // .setAutoCancel(true).setSmallIcon(R.mipmap.ic_launcher_round).build();}Overridepublic int onStartCommand(Intent intent, int flags, int startId) {Log.d(TAG, onStartCommand);startForeground(1, getNotification());registerBroadcast();return START_STICKY;}Overridepublic void onDestroy() {super.onDestroy();Log.d(TAG, onDestroy);unregisterBroadcast();stopForeground(true);stopSelf();}NullableOverridepublic IBinder onBind(Intent intent) {return null;}public void registerBroadcast() {Log.d(TAG, registerBroadcast);IntentFilter intentFilter new IntentFilter();intentFilter.addAction((Intent.ACTION_SHUTDOWN));registerReceiver(mShutdownBroadcastReceiver,intentFilter);}public void unregisterBroadcast() {if (mShutdownBroadcastReceiver ! null) {unregisterReceiver(mShutdownBroadcastReceiver);}} }4.关机广播实现 package com.android.mytest;import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log;public class ShutdownBroadcastReceiver extends BroadcastReceiver {private static final String TAG ShutdownBroadcastReceiver;Overridepublic void onReceive(Context context, Intent intent) {Log.d(TAG, zjy onReceive intent:intent);} }5.本地验证
http://www.w-s-a.com/news/82184/

相关文章:

  • 网站seo技术wordpress editor ios
  • 红酒网站设计成立公司需要哪些手续
  • 广州做网站哪个好网站建网站建设网站站网站
  • 如何快速提升网站pr短剧个人主页简介模板
  • 上海网站建设 永灿百度权重3的网站值多少
  • 公司展示网站模板模板工
  • 网站建设收费详情舟山公司做网站
  • 深圳宝安区住房和建设局网站html模板大全
  • 和田哪里有做网站的地方wordpress地址更改
  • 恒通建设集团有限公司网站企业网站百度指数多少算竞争大
  • 雅虎网站收录提交入口如何使用wordpress搭建网站
  • 微商城网站建设怎么样发稿是什么意思
  • dz建站与wordpress群晖做网站服务器速度快吗
  • 做手机网站的公司网站建设 app开发 图片
  • 网站开发技术背景介绍wordpress数据库重置密码
  • 开发建设网站的实施过程是一个logo设计品牌
  • 做360pc网站排名首页工程造价信息网官网首页
  • 产品销售网站模块如何设计大数据和网站开发
  • 现在帮别人做网站赚钱不济南做网站建设公司
  • 嘉兴网站建设哪家好最近三天的国际新闻大事
  • 安丘网站建设制作做网站口碑比较好的大公司
  • 成都专业做网站公司哪家好优化大师下载安装免费
  • 防蚊手环移动网站建设广东深圳有几个区
  • 网站建设找哪些平台宜兴网站开发
  • 免费网站应用软件wordpress添加动态图标
  • 中小企业网站建设客户需求调查问卷昆明网站建设一条龙
  • 网站内容的特点wordpress 移动端网页
  • 专门网站建设培训网站系统建设
  • 自己设计手机的网站wordpress主题加密教程
  • 北京网站建设公司飞沐卖水果网站建设的策划书