android卸载程序代码
来源:互联网 发布:js页面时间格式化 编辑:程序博客网 时间:2024/05/21 11:17
android卸载程序代码
2011-11-13 13:37:10| 分类:android | 标签:android |字号大中小 订阅
安装:
Java代码
- String str = "/CanavaCancel.apk";
- String fileName = Environment.getExternalStorageDirectory() + str;
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
- startActivity(intent);
卸载: <uses-permission android:name="android.permission.DELETE_PACKAGES"></uses-permission>
Java代码
- Uri packageURI = Uri.parse("package:com.demo.CanavaCancel");
- Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
- startActivity(uninstallIntent);
package:com.demo.CanavaCancel 这个形式是 package:程序完整的路径 (包名+程序名).
下载apk程序代码:
Java代码
- protected File downLoadFile(String httpUrl) {
- // TODO Auto-generated method stub
- final String fileName = "updata.apk";
- File tmpFile = new File("/sdcard/update");
- if (!tmpFile.exists()) {
- tmpFile.mkdir();
- }
- final File file = new File("/sdcard/update/" + fileName);
- try {
- URL url = new URL(httpUrl);
- try {
- HttpURLConnection conn = (HttpURLConnection) url
- .openConnection();
- InputStream is = conn.getInputStream();
- FileOutputStream fos = new FileOutputStream(file);
- byte[] buf = new byte[256];
- conn.connect();
- double count = 0;
- if (conn.getResponseCode() >= 400) {
- Toast.makeText(Main.this, "连接超时", Toast.LENGTH_SHORT)
- .show();
- } else {
- while (count <= 100) {
- if (is != null) {
- int numRead = is.read(buf);
- if (numRead <= 0) {
- break;
- } else {
- fos.write(buf, 0, numRead);
- }
- } else {
- break;
- }
- }
- }
- conn.disconnect();
- fos.close();
- is.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return file;
- }
打开APK程序代码:
Java代码
- private void openFile(File file) {
- // TODO Auto-generated method stub
- Log.e("OpenFile", file.getName());
- Intent intent = new Intent();
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setAction(android.content.Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.fromFile(file),
- "application/vnd.android.package-archive");
- startActivity(intent);
- }
- android卸载程序代码
- android卸载程序代码
- 卸载程序代码
- 在Android程序代码中实现软件安装和卸载
- 在Android程序代码中实现软件安装和卸载
- 在Android程序代码中实现软件安装和卸载
- 在Android程序代码中实现软件安装和卸载
- Android 在程序代码中控制软件的卸载与安装
- Android 退出整个程序代码
- android退出程序代码总结
- Android发送程序代码
- Android客户端程序代码
- Android一些核心功能程序代码
- android 2.2 完全 退出 ---程序代码
- Android重启应用程序代码
- Android重启应用程序代码
- Android重启应用程序代码
- Android 蓝牙聊天程序代码实例
- C/C++软件工程师就业求职手册
- popcap sexyframework - Demo1 基本框架
- 2012 沈阳 应届生找工作(续)
- 我想写博客的原因
- 编码释疑
- android卸载程序代码
- 一个 灵活 轻量级 实时 Linux 调试器 和跟踪器:KGTP
- popcap sexyframework - Demo2 图像 声音 字体 窗体部件 按钮 事件 监听器
- iProperties 简述
- javascript何时执行的问题。
- popcap sexyframework - Demo3 对图像进行 修改 拉伸 翻转 做动画 以及 按钮 和 鼠标事件
- popcap sexyframework- Demo4 使用资源管理器加载资源 前导屏幕 播放声音 以及超连接 输入框 列表框 滚动条
- Spring AOP 实现原理与CGLIB应用
- popcap sexyframework - Demo5 键盘输入 对话框 滑动条 设置音量