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

有网站前台百度引擎入口官网

有网站前台,百度引擎入口官网,怎么对网站标注做记号,写网站教程做一个应用,需要强制关闭进程。 可以使用ActivityManager的killBackgroundProcesses方法,需要权限android.permission.KILL_BACKGROUND_PROCESSES。但使用此方法杀死进程后,进程会重启。源码中解释如下: Have the system immediat…

做一个应用,需要强制关闭进程。

可以使用ActivityManager的killBackgroundProcesses方法,需要权限android.permission.KILL_BACKGROUND_PROCESSES。但使用此方法杀死进程后,进程会重启。源码中解释如下:

Have the system immediately kill all background processes associated with the given package.  This is the same as the kernel killing those processes to reclaim memory; the system will take care of restarting these processes in the future as needed.


为了强制关闭进程,希望使用ActivityManager的另外一个方法,forceStopPackage。源码中解释如下:

Have the system perform a force stop of everything associated with the given application package.  All processes that share its uid will be killed, all services it has running stopped, all activities removed, etc.  In addition, a {@link Intent#ACTION_PACKAGE_RESTARTED} broadcast will be sent, so that any of its registered alarms can be stopped, notifications removed, etc.

使用这个方法有两点需要注意:

- 此方法是@hide的方法:

解决方案是使用java的反射机制完成调用,代码如下:

[java]  view plain copy print ?
  1. ActivityManager mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);  
  2. Method method = Class.forName("android.app.ActivityManager").getMethod("forceStopPackage", String.class);  
  3. method.invoke(mActivityManager, packageName);  //packageName是需要强制停止的应用程序包名  

- 此方法需要权限:android.permission.FORCE_STOP_PACKAGES

下面着手分析这个权限。

这个权限在frameworks/base/core/res/AndroidManifest.xml文件中声明,如下:

[java]  view plain copy print ?
  1.   
[html]  view plain copy print ?
  1. <permission android:name="android.permission.FORCE_STOP_PACKAGES"  
  2.  android:permissionGroup="android.permission-group.SYSTEM_TOOLS"  
  3.  android:protectionLevel="signature"  
  4.  android:label="@string/permlab_forceStopPackages"  
  5.  android:description="@string/permdesc_forceStopPackages"/>  

注意protectionLevel属性值未signature。看sdk文档http://developer.android.com/guide/topics/manifest/permission-element.html#plevel中对这一属性的解释如下:

A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.

意思是:app使用FORCE_STOP_PACKAGES权限,app必须和这个权限的声明者的签名保持一致!

FORCE_STOP_PACKAGES的声明者是frameworks/base/core/res/,可以在frameworks/base/core/res/Android.mk中看到它的签名信息:

[html]  view plain copy print ?
  1. LOCAL_NO_STANDARD_LIBRARIES :true  
  2. LOCAL_PACKAGE_NAME :framework-res  
  3. LOCAL_CERTIFICATE :platform  

即,签名为platform. 

最终得到结论,app需要是platform签名,才可以使用forceStopPackage方法!

网上有很多文章提及,需要在app的AndroidManifest.xml中添加android:sharedUserId="android.uid.system"一句话。看sdk(http://developer.android.com/guide/topics/manifest/manifest-element.html)对此的解释:

android:sharedUserId
The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.
意思是,两个app使用了相同的user id,就可以互相访问对方的数据。因此,app使用android.uid.system的user id,就可以访问系统数据。注意背景为黄色的一句,这里依然需要两个app有相同的签名才行。


http://www.khdw.cn/news/63055.html

相关文章:

  • 毕业设计做网站还是系统好郑州网站建设用户
  • 保定免费建站疫情最新消息今天
  • 哈尔滨网站建设费用宁波seo公司排名
  • 做app 的模板下载网站有哪些代运营
  • 流行用什么做网站seo是什么平台
  • 有哪些公司的网站做的很好看有人看片吗免费的
  • 网站前端开发商业策划公司十大公司
  • 温州高端网站建设公司培训机构排名前十
  • 六安网站自然排名优化价格域名备案查询
  • 深圳模板网站制作关键词批量调词软件
  • 服装加工网seo销售是做什么的
  • 内页网站地图 权重新媒体营销案例
  • 网站排版设计欣赏seo联盟
  • litespeed wordpress百度seo新站优化
  • dw网页制作试题上海网站优化公司
  • 专业ppt代做seo搜索优化推广
  • 微网站制作提供商推荐优化公司
  • 真人做爰网站视频网络推广公司官网
  • 中国万网联系方式百度seo快速见效方法
  • 建歌网站多少钱seo点击软件
  • 下载官方网站app下载百度竞价推广开户
  • 网站建设公司广告语宣传语关键词排名点击软件怎样
  • 网站设置反爬虫的主要原因如何提高网站在百度的排名
  • 微信网站建设报价营销策略ppt模板
  • 电脑网站建设方案上海百度推广客服电话
  • 济南免费网站制作农产品网络营销
  • 软件测试与网站建设哪个好超级搜索引擎
  • 怎么做快法务类似网站关键词排名优化怎么样
  • 集团企业网工管理系统台州关键词优化报价
  • 网站资源做缓存好用的推广平台