安装:从sdcard
- String fileName = Environment.getExternalStorageDirectory() + "/myApp.apk";
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.parse("file://" + filePath),"application/vnd.android.package-archive");
- 或者
- //intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
- startActivity(intent);
卸载
- Uri packageURI = Uri.parse("package:com.android.myapp");
- Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
- startActivity(uninstallIntent);
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/fenghome/archive/2010/06/16/5673757.aspx
本文介绍了如何在安卓设备上实现应用程序的安装与卸载操作。通过使用Intent和Uri组件,可以轻松地从外部存储中启动应用安装流程,并且能够发起针对特定包名的应用卸载指令。
1113

被折叠的 条评论
为什么被折叠?



