android 启动第三方程序的代码&&&&android 安装卸载原理 以及activity 根据包名和应用名启动应用程序
来源:互联网 发布:广西银河商品交易软件 编辑:程序博客网 时间:2024/05/22 06:59
android 启动第三方程序的代码
//启动媒体库
Intent i = new Intent();
ComponentName comp = new ComponentName("com.android.camera","com.android.camera.GalleryPicker");
i.setComponent(comp);
i.setAction("android.intent.action.VIEW");
startActivity(i);
//启动相机
Intent mIntent = new Intent();
ComponentName comp = new ComponentName("com.android.camera","com.android.camera.Camera");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivity(mIntent);
//启动htmlviewer,并打开指定的一个文件 注意TXT不能是ANSI的,否则会乱码
Intent intent = new Intent();
ComponentName cn = new ComponentName("com.android.htmlviewer", "com.android.htmlviewer.HTMLViewerActivity");
intent.setComponent(cn);
Uri uri = Uri.fromFile(new File("/sdcard/demo.txt"));
intent.setDataAndType(uri, "text/plain");
startActivity(intent);
首先apk安装涉及几个目录,system/app (系统自带的应用程序,无法删除)、data/app(用户程序安装的目录,有删除权限。安装时把apk文件复制到此目录)、data/data(存放应用程序的数据)、Data/dalvik-cache(将apk中的dex文件安装到dalvik-cache目录下(dex文件是dalvik虚拟机的可执行文件,其大小约为原始apk文件大小的四分之一)) 。。。
安装过程:复制APK安装包到data/app目录下,解压并扫描安装包,把dex文件(Dalvik字节码)保存到dalvik-cache目录,并data/data目录下创建对应的应用数据目录。
卸载过程:删除安装过程中在上述三个目录下创建的文件及目录。
一、系统应用安装:
PackageManagerService处理各种应用的安装,卸载,管理等工作,开机时由systemServer启动此服务
(源文件路径:android\frameworks\base\services\java\com\android\server\PackageManagerService.java)
PackageManagerService服务启动的流程:
1.
首先扫描安装“system\framework”目录下的jar包
1.
scanDirLI(mFrameworkDir,PackageParser.PARSE_IS_SYSTEM,
scanMode | SCAN_NO_DEX);
2.第二步扫描安装“system\app”目录下的各个系统应用
scanDirLI(mSystemAppDir,PackageParser.PARSE_IS_SYSTEM, scanMode);
3.第三步扫描“data\app”目录,即用户安装的第三方应用
scanDirLI(mAppInstallDir, 0, scanMode);
4.第四步扫描" data\app-private"目录,即安装DRM保护的APK文件(目前没有遇到过此类的应用)。
scanDirLI(mDrmAppPrivateInstallDir,0, scanMode | SCAN_FORWARD_LOCKED);
看到这里相信你已经对apk的安装卸载有些头目了吧,接来下请看这个,会让你柳暗花明的:
activity 根据包名和应用名启动应用程序:
final ComponentName cn = new ComponentName(app.appname.substring(0,
"com.eshore.efilm", "com.eshore.efilm.Efilm");
Intent intent = new Intent();
intent.setComponent(cn);
intent
.setAction("android.intent.action.VIEW");
startActivity(intent);
Android程序使用代码的安装和卸载!!!
this should work:
Java:
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);
that's because intent filter is:
XML:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="application/vnd.android.package-archive" />
</intent-filter>
</activity>
intent filter for uninstallation:
XML:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
</activity>
- android 启动第三方程序的代码&&&&android 安装卸载原理 以及activity 根据包名和应用名启动应用程序
- activity 根据包名和应用名启动应用程序
- Android 根据apk获取应用包名和启动Activity
- 怎么找android应用的包名和启动activity
- Android根据包名 启动 删除 应用
- Android根据包名启动应用
- Android - 在一个应用程序中启动另外一个已经安装的应用程序或系统程序(前提是要知道该应用程序的主activity和包名)
- Android根据包名启动或者销毁activity
- Android获取Apk包名和启动的Activity
- android APK包名和启动的Activity
- android 获取第三方应用程序包名并启动
- android 获取第三方应用程序包名并启动
- android 获取第三方应用程序包名并启动
- 手把手教你_怎么找android应用的包名和启动activity
- 手把手教你_怎么找android应用的包名和启动activity
- android 开发如何获得第三方应用Widget的包名和类名
- android 读取本地安装app 包名并启动第三方app
- Android--adb命令查看第三方应用包名、应用activity名
- 无线网络知识补充
- eclipse字体及背景设置
- HTTP协议详解
- 2015年中国人才招聘趋势报告
- 什么是IaaS, PaaS和SaaS及其区别
- android 启动第三方程序的代码&&&&android 安装卸载原理 以及activity 根据包名和应用名启动应用程序
- 北大ACM试题1010-暴力搜索
- 9 个重量级的云计算(PaaS)平台
- CentOS 网络配置
- 天声人語 20150409
- 使用npm安装一些包失败了的看过来(npm国内镜像介绍)
- [Leetcode] 129. Sum Roof to Leaf Numbers
- Cocos2d-x 设计模式 -- 单例设计模式
- selenium webdriver 悬停事件调查整理!!