在Android安装卸载程序的源码中我们知道:
- < activity android:name=".PackageInstallerActivity">
- < intent-filter>
-
< action android:name="android.intent.action.VIEW" />
-
< category android:name="android.intent.category.DEFAULT" />
-
< data android:scheme="content" />
-
< data android:scheme="file" />
-
< data android:mimeType="application/vnd.android.package-archive" />
- < /intent-filter>
- < /activity>
-
-
< activity android:name=".UninstallerActivity">
- < intent-filter>
-
< action android:name="android.intent.action.VIEW" />
-
< action android:name="android.intent.action.DELETE" />
-
< category android:name="android.intent.category.DEFAULT" />
-
< data android:scheme="package" />
- < /intent-filter>
- < /activity>
< activity android:name=".PackageInstallerActivity">
< intent-filter>
< action android:name="android.intent.action.VIEW" />
< category android:name="android.intent.category.DEFAULT" />
< data android:scheme="content" />
< data android:scheme="file" />
< data android:mimeType="application/vnd.android.package-archive" />
< /intent-filter>
< /activity>
< activity android:name=".UninstallerActivity">
< intent-filter>
< action android:name="android.intent.action.VIEW" />
< action android:name="android.intent.action.DELETE" />
< category android:name="android.intent.category.DEFAULT" />
< data android:scheme="package" />
< /intent-filter>
< /activity>
因为根据里面的权限我们可以 从sd卡安装一个程序:
- String fileName = Environment.getExternalStorageDirectory() + "/myApp.apk";
-
Intent intent = new Intent(Intent.ACTION_VIEW);
-
-
intent.setDataAndType(Uri.parse("file://" + filePath),"application/vnd.android.package-archive");
-
-
-
- startActivity(intent);
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);
Android安装卸载程序的操作中要想卸载一个程序;
- Uri packageURI = Uri.parse("package:com.android.myapp");
-
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
- startActivity(uninstallIntent);
Uri packageURI = Uri.parse("package:com.android.myapp");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
默认是不支持安装非市场程序的 因此判断一下
- int result = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, 0);
-
if (result == 0) {
-
-
-
-
Intent intent = new Intent();
- intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);
- startActivity(intent);
- }
- 转载:http://panxq0809.iteye.com/blog/668772
分享到:
相关推荐
Android APK的安装卸载 Android APK的安装卸载
android卸载已安装应用代码,提供点击打开应用功能,采用ListView显示所有已安装应用(剔除了原装应用)。 在此代码中可以学到,ListView自定义适配器的使用,ListView中给每条Item加按钮并实现ListView的Item与按钮...
Android模拟器中安装和卸载程序 模拟器安装 模拟器卸载 安装和卸载 有图片
Android应用卸载器源码,完整应用。
通过AIDL调用Android源码静默安装卸载APK....
卸载安卓手机上的已安装程序的代码,剔除了原装软件。主要实现了打开应用程序和卸载应用程序功能。
电脑上有腾讯管家,作为安卓开发,用真机测试的比较多,鄙人算一个,不喜欢用应用宝,当你卸载了应用...今天又死机了一次,决定做一个当应用宝安装后弹出卸载框的程序 来提示我们卸载这个可恶的应用宝,我用的是华为3x
91手机助手forAndroid安装卸载软件教程借鉴.pdf
91手机助手forAndroid安装卸载软件教程整理.pdf
一个非常方便小巧的Android程序卸载工具,只需要简单的双击需要卸载的软件即可启动卸载程序~~
Android通过调用C来监听自己的程序被卸载。
通过batch实现的android应用批量安装卸载工具,有代码,有使用说明,欢迎下载
android应用卸载提示 利用监控log机制监控自己被卸载,卸载时提示。
Android疯子卸载
Android中的监听应用程序如何安装和卸载
Android例子源码root后静默安装卸载应用
android 实现自我自动静默卸载 妈妈再也不用担心我是流氓了 部分手机安装失败。本人三星i9108可以 小米安装失败。不知道为什么。同个程序。可能是小米没root,但是代码里面没有涉及root相关的 。只是修改了应用权限 ...
内附apk 实现说明 是在linx系统环境下 源码下MM 编译实现方式
在程序中处理卸载apk,我是在这个情况下用到的与大家共享:开始apk上线用的是debug签名,后我换了台电脑,导致打包再上线报签名不一致的问题.后采用数字证书签名并修改了游戏的主类包名.解决签名不一致的问题. 这样导致...
Android10.0 静默安装、卸载接口