android 添加,删除程序
16lz
2021-01-23
1. 安装程序
- StringfileName=Environment.getExternalStorageDirectory()+"/myApp.apk";
- Intentintent=newIntent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.parse("file://"+filePath),"application/vnd.android.package-archive");
- //或者
- //intent.setDataAndType(Uri.fromFile(newFile(fileName)),"application/vnd.android.package-archive");
- startActivity(intent);
2.删除程序
- UripackageURI=Uri.parse("package:com.android.myapp");
- IntentuninstallIntent=newIntent(Intent.ACTION_DELETE,packageURI);
- startActivity(uninstallIntent);
默认是不支持安装非市场程序的 因此判断一下
- intresult=Settings.Secure.getInt(getContentResolver(),Settings.Secure.INSTALL_NON_MARKET_APPS,0);
- if(result==0){
- //showsomedialoghere
- //...
- //andmaybeshowapplicationsettingsdialogmanually
- Intentintent=newIntent();
- intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);
- startActivity(intent);
- }
更多相关文章
- android 模拟器中找不到程序
- 程序人生之Android学习路线图
- Android对应用程序的资源文件xml解析的源代码在哪里
- 至2013年5月初android各个版本市场占有情况
- 调用Android installer 安装和卸载程序
- 为什么要在 Windows 10 系统上运行 Android 应用程序?