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

用ps做网站html导航栏模板

用ps做网站,html导航栏模板,购物网站开发英文文献,网页简单制作流程WakefulBroadcastReceiver 是一种特殊类型的广播接收器#xff0c;为应用创建和管理 PARTIAL_WAKE_LOCK 。 简单来说#xff0c; WakefulBroadcastReceiver 是持有系统唤醒锁的 BroadcastReceiver #xff0c;用于执行需要保持CPU运转的场景。 注册 注册 Receiver #…WakefulBroadcastReceiver 是一种特殊类型的广播接收器为应用创建和管理 PARTIAL_WAKE_LOCK 。 简单来说 WakefulBroadcastReceiver 是持有系统唤醒锁的 BroadcastReceiver 用于执行需要保持CPU运转的场景。 注册 注册 Receiver receiver android:name.MyWakefulReceiver/receiver实现MyWakefulReceiver 重写 onReceive() 方法使用 startWakefulService(Context context, Intent intent) 启动 Service public class MyWakefulReceiver extends WakefulBroadcastReceiver {Overridepublic void onReceive(Context context, Intent intent) {// Start the service, keeping the device awake while the service is// launching. This is the Intent to deliver to the service.Intent service new Intent(context, MyIntentService.class);startWakefulService(context, service);}} Service Service 里执行正常的逻辑实行结束后调用 MyWakefulReceiver.completeWakefulIntent(Intent intent) 方法。 public class MyIntentService extends IntentService {public MyIntentService() {super(MyIntentService);}Overrideprotected void onHandleIntent(Intent intent) {Bundle extras intent.getExtras();// Do the work that requires your app to keep the CPU running.// ...// Release the wake lock provided by the WakefulBroadcastReceiver.MyWakefulReceiver.completeWakefulIntent(intent);} }源码分析 在 startWakefulService(Context context, Intent intent) 方法中通过 PowerManager.WakeLock 持有了系统锁并为每个 intent 设置了一个 id 用于标识存储在 sActiveWakeLocks 数组中 /*** Do a {link android.content.Context#startService(android.content.Intent)* Context.startService}, but holding a wake lock while the service starts.* This will modify the Intent to hold an extra identifying the wake lock;* when the service receives it in {link android.app.Service#onStartCommand* Service.onStartCommand}, it should pass back the Intent it receives there to* {link #completeWakefulIntent(android.content.Intent)} in order to release* the wake lock.** param context The Context in which it operate.* param intent The Intent with which to start the service, as per* {link android.content.Context#startService(android.content.Intent)* Context.startService}.*/public static ComponentName startWakefulService(Context context, Intent intent) {synchronized (sActiveWakeLocks) {int id mNextId;mNextId;if (mNextId 0) {mNextId 1;}intent.putExtra(EXTRA_WAKE_LOCK_ID, id);ComponentName comp context.startService(intent);if (comp null) {return null;}PowerManager pm (PowerManager)context.getSystemService(Context.POWER_SERVICE);PowerManager.WakeLock wl pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,androidx.core:wake: comp.flattenToShortString());wl.setReferenceCounted(false);wl.acquire(60 * 1000);sActiveWakeLocks.put(id, wl);return comp;}}当 Service 调用 MyWakefulReceiver.completeWakefulIntent(Intent intent) 方法时释放系统锁并根据 id 将此锁从数组中移除 /*** Finish the execution from a previous {link #startWakefulService}. Any wake lock* that was being held will now be released.** param intent The Intent as originally generated by {link #startWakefulService}.* return Returns true if the intent is associated with a wake lock that is* now released; returns false if there was no wake lock specified for it.*/public static boolean completeWakefulIntent(Intent intent) {final int id intent.getIntExtra(EXTRA_WAKE_LOCK_ID, 0);if (id 0) {return false;}synchronized (sActiveWakeLocks) {PowerManager.WakeLock wl sActiveWakeLocks.get(id);if (wl ! null) {wl.release();sActiveWakeLocks.remove(id);return true;}// We return true whether or not we actually found the wake lock// the return code is defined to indicate whether the Intent contained// an identifier for a wake lock that it was supposed to match.// We just log a warning here if there is no wake lock found, which could// happen for example if this function is called twice on the same// intent or the process is killed and restarted before processing the intent.Log.w(WakefulBroadcastReceiv., No active wake lock id # id);return true;}}
http://www.w-s-a.com/news/7988/

相关文章:

  • 专业网站建设的公司wordpress后台没有模板
  • 哈尔滨网站运营服务商制作外贸网站公司
  • 个人网站需要备案宁波网站推广工具
  • 苏州建设银行网站首页wordpress修改密码
  • 网站建设员工技能要求网站制作简单协议
  • 没有ipc备案的网站wordpress isux主题
  • 清远做网站电子商务网站建设需要的语言及特点6
  • 万州那家做网站c语言基础知识入门
  • 齐河网站建设公司价格网站建设包括什么
  • 论坛网站开发费用怎么把文件放到网站的根目录
  • 海南省零售户电商网站官渡区住房和城乡建设局网站
  • 怎么找淘宝客网站最新军事战况
  • 缺乏门户网站建设网页设计与制作项目教程第二版
  • 手机网站横竖屏一般做建设的是什么公司
  • 免费网站建设无广告网站开发 华景新城
  • 湖州网站制作报价西安网站开发有哪些公司
  • google 浏览器开源seo软件
  • 网站空间是什么意思自己怎样建设网站
  • 国外家装设计网站如何做软件开发
  • 凡科建站登录官网当当网网站建设策划书
  • 网站百度屏蔽关键词杭州排名优化公司
  • h5响应式网站模板下载wordpress鼠标指针
  • 摄影作品投稿网站目前最好的引流推广方法
  • 资源站源码永久dede网站搬家 空间转移的方法
  • 网站建设销售的技巧话语it培训机构
  • 自建本地网站服务器wordpress南充房产网最新楼盘最近房价
  • 郑州代做网站天津哪里能做网站
  • 网站如何做排名网站建设项目的工作分解
  • 洛阳网络建站公司网站开发主流语言
  • 广州各区正在进一步优化以下措施seo值是什么意思