合并android清单文件,过滤器冲突 [英] Merging android manifest files, conflicting filter

查看:146
本文介绍了合并android清单文件,过滤器冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Unity中2个插件的android清单文件组合在一起,但是有两个活动具有相同的intent-filter,而我只能同时获得1个或另一个活动....

在两个冲突的活动中,清单文件中最上面的那一项将起作用.因此,如果清单1中的活动位于最前面,则插件1将起作用,但插件2将不起作用,反之亦然.

两个相互冲突的活动是:

<activity
        android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
        android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity> 

并且:

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" 
android:label="@string/app_name" android:screenOrientation="portrait" 
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

有什么办法可以合并两者并使它们在同一应用程序中工作?我正在使用Unity 3d.

解决方案

例如,在清单中,您仅想将第一个活动用作启动器,则必须添加以下2个修改:

清单清单的开头

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

对于要删除其意图过滤器的活动,请添加以下代码:

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" 
android:label="@string/app_name" android:screenOrientation="portrait" 
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter tools:node="removeAll">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

重要的部分是在intent-filter标记中添加 tools:node ="removeAll" 属性

I'm trying to combine android manifest files from 2 plugins in Unity, but there are two activities with the same intent-filter and I can only get 1 or the other to work at the same time....

Of the 2 conflicting activities, whichever is on top in the manifest file is the one that will work. So if activity from manifest #1 is on top, plugin #1 will work but not #2, and vice versa.

The two conflicting activities are:

<activity
        android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
        android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity> 

And:

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" 
android:label="@string/app_name" android:screenOrientation="portrait" 
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

is there any way I can merge the two and get them to work from the same app? I'm using Unity 3d.

解决方案

For example in the manifest where you want to use only the first activity as launcher you have to add this 2 modifications:

At the beginning of the manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

And for the activity for which you want to remove the intent filter add this code:

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" 
android:label="@string/app_name" android:screenOrientation="portrait" 
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter tools:node="removeAll">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

The important part is to add the tools:node="removeAll" attribute in the intent-filter tag

这篇关于合并android清单文件,过滤器冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆