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

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

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

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

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

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

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

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

                
    1. intresult=Settings.Secure.getInt(getContentResolver(),
      Settings.Secure.INSTALL_NON_MARKET_APPS,0);
    2. if(result==0){
    3. //showsomedialoghere
    4. //...
    5. //andmaybeshowapplicationsettingsdialogmanually
    6. Intentintent=newIntent();
    7. intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);
    8. startActivity(intent);
    9. }

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

更多相关文章

  1. Android 自定义View及其在布局文件中的使用示例(三):结合Android
  2. Android之查看外部依赖jar的源码_android private libralies doe
  3. Android上的Adobe AIR应用程序运行环境发布了!
  4. 一个提供Android各历史版本在线源码的网址
  5. android通过USB使用真机调试程序
  6. 《程序人生 —— Android实现录音、播音、录制视频功能》

随机推荐

  1. Android(安卓)-- Android(安卓)JUint 与
  2. 【Android(安卓)volley】Android库Volley
  3. Android(安卓)主流图片库Picasso Glide F
  4. Android(安卓)Q 电量使用图分析 show app
  5. 【startActivityForResult】Android(安卓
  6. [android源码下载索引贴】微信+二维码那
  7. Android中OpenMax的适配层
  8. Android中,把XML文件转换成Object对象的方
  9. android:制作system.img(yaffs2)镜像
  10. Android上的模拟点击