【原创】android 中安装应用程序方法及代码
来源:互联网 发布:人工智能在银行的应用 编辑:程序博客网 时间:2024/06/08 03:50
//①通过market获取程序,这样必须保证market上的pname为最新的
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("market://search?q=pname:com.sdddz"));
startActivity(intent);
//②通过intent机制安装
Uri uri = Uri.fromFile(new File(fileName));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri,"application/vnd.android.package-archive");
startActivity(intent);
//③直接调用安装接口,安装权限:android.permission.INSTALL_PACKAGES
Uri mPackeageURI = Uri.fromFile(new File(Environment.getExternalStorageDirectory()+apkName));
int installFlag = 0;
PackageManager pm = getPackageManager();
try{
PackageInfo pi = pm.getPackageInfo(packageName,PackageManager.GET_UNINSTALLED_PACKAGES);
if(pi != null){
installFlag |= PackageManager.REPLACE_EXISTING_PACKAGE;
}
}catch(NameNotFoundException e){
e.printStrackTrace();
}
PackageInstallObserver observer = new PackageInstallObserver();
pm.installPackage(mPackageURI,observer,installFlag);
//④执行install命令 不附上-r会清楚原有数据(这个方法还没有搞清楚请,是需要在这个页面里执行命令吗)
install -r
am start ..
Runtime.exec(String[] args)
Class<?> execClass = Class.forName("android.os.Exec");
方法的①②③可用于下载APK更新自动安装使用,④还没试过。
- 【原创】android 中安装应用程序方法及代码
- Android中让应用程序自动安装到手机内存及判断应用程序是否安装在SDCard中
- (转)Android中让应用程序自动安装到手机内存及判断应用程序是否安装在SDCard中
- android中得到所有安装的应用程序及区分其是否为系统应用程序还是用户应用程序
- LINUX手动安装git及repo android代码下载方法
- Android 客户端自动升级代码及“应用程序未安装”的解决办法
- Android 客户端自动升级代码及“应用程序未安装”的解决办法
- adb安装及删除Android应用程序apk
- 【原创】VB6.0应用程序安装包的生成(Setup Factory 9.0制作安装包的方法)
- android中通过代码启动应用程序
- Android中在native层对java层应用程序发送广播方法及原理
- 【原创】Android中ImageButton自定义按钮的按下效果的代码实现方法,附网上2种经典解决方法。
- android开发中应用程序未安装解决办法
- Android 中设置应用程序安装位置
- android应用程序中引用系统资源的方法
- android中获取应用程序版本的方法
- android 中退出当前应用程序的方法
- Android中访问应用程序的一些方法
- oracle表分区详解--学习一下
- Gladinet license
- vb.net datagridview 使用方法
- 关于error C2664
- 如何搭建hadoop
- 【原创】android 中安装应用程序方法及代码
- 五大主流浏览器CSS3和HTML5兼容性比拼
- [异常]Support for specifying both a day-of-week AND a day-of-month parameter is no
- SQL 补课
- 比较不错的资源搜索网站
- [2011-6-8]Ei&ISTP检索的第三届计算智能与软件工程(CiSE 2011)国际学术会议
- mini6410安装愤怒的小鸟
- 多线程学习
- JQuery选择器大全