手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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 WakeLock使用方法代码实例

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

刷新android中的媒体库

基于Android中实现定时器的3种解决方法

android 弹出提示框的使用(图文实例)

android开发基础教程—打电话发短信

Android 原始资源文件的使用详解

android 进程的优先级

android自动化测试中实现长按并拖动

基于Android设计模式之--SDK源码之策略模式的详解

精品推荐
分类导航