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(安卓)手机QQ临时会话
  3. 生成不同ABI版本APK在build.gradle中的配置
  4. android群发短信时判断短信是否发送成功
  5. Android(安卓)studio实现简单的计算器
  6. Android(安卓)service工具类,判断服务是否在运行
  7. Android抓屏源码
  8. 判断Android设备是否连接网络
  9. Android4.0中修改挂断键(ENDCALL)的默认行为

随机推荐

  1. Android JNI入门
  2. Android几种常见 自定义Button样式
  3. Android Binder概述
  4. Solution of issue: Android soft keyboa
  5. android学习笔记之AIDL
  6. 提升Android开发效率的5个经验总结【同行
  7. sqlite3加密方案sqlcipher,及sqlcipher使
  8. Android之SQLite数据库使用
  9. Android中XML绘图:Bitmap/Shape/Seletor和
  10. 同一功能在Android不同版本进行兼容的方