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. xml解析(一) XmlPullParser的使用
  2. 基于Android的推箱子小游戏 源码
  3. 【android】查看软件布局神器Hierarchy V
  4. Android之MIME TYPE
  5. H5调android 的方法修改UI无效
  6. cocos2d-x 编译成android apk常见错误
  7. android的ndk修改app_platform的方法,亲测
  8. Android字体设置
  9. Android一个Adapter的写法
  10. 音频的播放