android软件安装器

http://houjunli001.javaeye.com/blog/617405

在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>

因为根据里面的权限我们可以 从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"); //或者 //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);

默认是不支持安装非市场程序的 因此判断一下

int result = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, 0); if (result == 0) { // show some dialog here // ... // and may be show application settings dialog manually Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_SETTINGS); startActivity(intent); }

更多相关文章

  1. Linux系统下安装android sdk的方法步骤
  2. 关于Android多项目依赖在Eclipse中无法关联源代码的问题解决 (an
  3. android 安装文件例子
  4. android launcher 资料
  5. Android(安卓)ADT 插件安装
  6. Android上传文件,客户端+服务器源码
  7. Android多媒体开发(2)————使用Android(安卓)NKD编译原版FFmpeg
  8. php直播源码安卓自定义Dialog设置自动消失
  9. android 软件源码

随机推荐

  1. 数据结构与算法专题——第九题 外排序
  2. netcore使用 jenkins + supervisor 实现s
  3. 女生适合做测试吗?当然可以,必须的!
  4. Linq 下的扩展方法太少了,您期待的 MoreLi
  5. jenkins + supervisor + ansible 实现net
  6. 数据结构与算法专题——第十题 输入法跳
  7. 三种方式让你轻松监控 EntityFramework
  8. 虚虚实实,亦假亦真的 ValueTuple,绝对能眩
  9. 毕业5年,3度转岗,阿里学姐教你如何一举跳槽
  10. QianBase数据存储和传输加密