<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">最近一段时间需要做一个android的应用,应用的主要功能是封装一些第三方公司提供的apk。因为之前应用开发的经验较少,针对该功能,我有三个疑问:</span>
1 怎样才能让第三方apk的图标不在launcher上显示?
2 和需求确认清楚:第三方应用要以插件apk的形式集成进应用,那问题来了,第三方应用怎么样才能以插件的方式集成进应用呢?
3 将多个插件apk集成进应用,如果用户在“设置-->应用管理”里将插件apk卸载,那么势必会影响到我的集成应用的显示插件apk了,怎样才能让其不影响我的应用显示呢?
第一个问题解决很简单,需要第三方应用在AndroidManifest.xml的Activity代码里做如下修改即可:
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<span style="color:#ff0000;"> <!-- <category android:name="android.intent.category.LAUNCHER" /> --></span>
</intent-filter>
</activity>
注掉截图代码片段中的LAUNCHER属性即可。
那接下来就是第二个问题了:怎样才能让第三方应用以插件apk提供给我,以方便我集成这些第三方apk呢? 在搜索了一圈之后,发现需要用AndroidManifest.xml里这两个属性来控制:android:sharedUserId和android:process ,只要让第三方apk中的sharedUserId和process值与我的集成应用manifest中的一致,既可保证这些个应用公用一个进程ID和进程名称,这样我就可以在我的应用中集成进来这多个应用了。设置sharedUserId与process的代码截图如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
<span style="color:#cc0000;background-color: rgb(255, 255, 255);"> android:sharedUserId="com.test"</span>
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
<span style="color:#ff0000;"> android:process="com.test.tool"</span>
android:theme="@style/AppTheme" >