手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android通过代码的形式来实现应用程序的安装与卸载
android通过代码的形式来实现应用程序的安装与卸载
摘要:因为应用程序的安装与卸载模块在android系统中已经写好了,所以我们只需要激活就行了注意:intent.setDataAndType(Ur...

因为应用程序的安装与卸载模块在android系统中已经写好了,所以我们只需要激活就行了

注意:

intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");这一句话中,第一个参数是要安装的apk的路径,第二个参数是apk所对应的类型。可以砸tomcat的安装目录下的conf目录下的web.xml中找到

程序运行截图:

android通过代码的形式来实现应用程序的安装与卸载1

代码实现如下:

1、main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="安装" android:onClick="install" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="卸载" android:onClick="uninstall" /> </LinearLayout>

【android通过代码的形式来实现应用程序的安装与卸载】相关文章:

android之计时器(Chronometer)的使用以及常用的方法

Android实现图片循环播放的实例方法

Android应用程序运行的性能设计

android 进程的优先级

刷新android中的媒体库

Android 完全退出应用程序的解决方法

Android笔记之:App调试的几个命令的实践与分析

Android实现发短信/彩信功能

android 复制 粘贴 剪切功能应用

android开发之蜂鸣提示音和震动提示的实现原理与参考代码

精品推荐
分类导航