1. 安装程序

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

2.删除程序

        
  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. }

更多相关文章

  1. android 模拟器中找不到程序
  2. 程序人生之Android学习路线图
  3. Android对应用程序的资源文件xml解析的源代码在哪里
  4. 至2013年5月初android各个版本市场占有情况
  5. 调用Android installer 安装和卸载程序
  6. 为什么要在 Windows 10 系统上运行 Android 应用程序?

随机推荐

  1. Android知识整理
  2. Android(安卓)SDK离线安装
  3. AndroidManfest
  4. Android热修复原理普及
  5. Android 4.0.3来了 优化系统
  6. [转]Android onActivityResult()不执行的
  7. Android Material Design: NavigationVie
  8. Android jni的调用过程JNI_OnLoad(),利用
  9. 修改Android自带的JAVA应用程序
  10. 【Android 开发】:Android五种布局的使用