手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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平台应用GPIO模拟IR控制车载DTV

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

android中选中菜单的显示跳转和隐式跳转的实例介绍

android 开发教程之日历项目实践(一)

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

Android 通过onDraw实现在View中绘图操作的示例

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

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

精品推荐
分类导航