Android安装卸载程序具体操作方法解析
创始人
2024-06-22 06:01:03
0

对于编程爱好者们来说,Android手机操作系统是一款非常实用的系统。他们可以进行各种Android应用程序的开发来满足自的应用需求。在这里我们就先来为大家讲解一下有关Android安装卸载程序的具体操作步骤。

在Android安装卸载程序的源码中我们知道:

  1. < activity android:name=".PackageInstallerActivity">   
  2. < intent-filter>   
  3. < action android:name="android.intent.action.VIEW" />   
  4. < category android:name="android.intent.category.DEFAULT" />   
  5. < data android:scheme="content" />   
  6. < data android:scheme="file" />   
  7. < data android:mimeType="application/vnd.android.package-archive" />   
  8. < /intent-filter>   
  9. < /activity>   
  10. < activity android:name=".UninstallerActivity">   
  11. < intent-filter>   
  12. < action android:name="android.intent.action.VIEW" />   
  13. < action android:name="android.intent.action.DELETE" />   
  14. < category android:name="android.intent.category.DEFAULT" />   
  15. < data android:scheme="package" />   
  16. < /intent-filter>   
  17. < /activity> 

因为根据里面的权限我们可以 安装一个程序从sd卡:

  1. String fileName = Environment.getExternalStorageDirectory() 
    + "/myApp.apk";   
  2. Intent intent = new Intent(Intent.ACTION_VIEW);   
  3. intent.setDataAndType(Uri.fromFile(new File(fileName)), 
    "application/vnd.android.package-archive");   
  4. startActivity(intent);  

Android安装卸载程序的操作中要想卸载一个程序;

  1. Uri packageURI = Uri.parse("package:com.android.myapp");   
  2. Intent uninstallIntent = new Intent
    (Intent.ACTION_DELETE, packageURI);   
  3. startActivity(uninstallIntent);  

默认是不支持安装非市场程序的 因此判断一下

  1. int result = Settings.Secure.getInt(getContentResolver(),
     Settings.Secure.INSTALL_NON_MARKET_APPS, 0);   
  2. if (result == 0) {   
  3. // show some dialog here   
  4. // ...   
  5. // and may be show application settings dialog manually   
  6. Intent intent = new Intent();   
  7. intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);   
  8. startActivity(intent);   

Android安装卸载程序的具体实现方法就为大家介绍到这里。

【编辑推荐】

  1. Android Jni代码示例讲解 
  2. Android单元测试源码解读 
  3. Android判断网络状态方法详解 
  4. Android程序架构基本内容概述 
  5. Android调用平台功能具体技巧分享 

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
着眼MAC地址,解救无法享受D... 在安装了DHCP服务器的局域网环境中,每一台工作站在上网之前,都要先从DHCP服务器那里享受到地址动...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...