手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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 弹出提示框的使用(图文实例)

android 复制 粘贴 剪切功能应用

android 进程的优先级

Android的webview支持HTML5的离线应用功能详细配置

Android控件之EditView常用属性及应用方法

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

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

Android的Service应用程序组件基本编写方法

android预置默认的语音信箱号码具体实现

Android的单位以及屏幕分辨率详解

精品推荐
分类导航