即时应用程序的单独清单
Separate manifest for instant app
我可以为免安装应用程序和常规应用程序使用不同的清单吗?
更详细地说,我需要在 "android:name=App"
字段(应用程序标签)中指定不同的 类 "App"。
为了帮助您开始,这里是 github 关于免安装应用程序的示例代码。您可以检查以下代码的结构:
<!--
~ Copyright 2017 Google Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.instantapps.samples.hello.feature">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".HelloActivity"
android:label="@string/title_activity_hello">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:autoVerify="true"
android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="hello.instantappsample.com" />
<data android:pathPrefix="/hello" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://hello.instantappsample.com/hello" />
</activity>
<activity
android:name=".GoodbyeActivity"
android:label="@string/title_activity_goodbye">
<intent-filter
android:autoVerify="true"
android:order="2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="hello.instantappsample.com" />
<data android:pathPrefix="/goodbye" />
</intent-filter>
</activity>
</application>
</manifest>
这里是 Manifest file structure 可以帮助您在构建阶段进一步发展。
The code snippet below shows the general structure of the manifest
file and every element that it can contain. Each element, along with
all of its attributes, is fully documented in a separate file.
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<uses-permission />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />
<uses-feature />
<supports-screens />
<compatible-screens />
<supports-gl-texture />
<application>
<activity>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity>
<activity-alias>
<intent-filter> . . . </intent-filter>
<meta-data />
</activity-alias>
<service>
<intent-filter> . . . </intent-filter>
<meta-data/>
</service>
<receiver>
<intent-filter> . . . </intent-filter>
<meta-data />
</receiver>
<provider>
<grant-uri-permission />
<meta-data />
<path-permission />
</provider>
<uses-library />
</application>
</manifest>
有几种方法可以做到这一点:
如果您必须有两个不同的清单,那么您将需要使用 tools:replace
,示例:
您安装的应用程序模块的清单:
<application
android:name="com.example.App"
tools:replace="android:name"/>
您的功能模块清单:
<application
android:name="com.example.feature.AppFeat">
构建安装型应用时,它将 运行 和 App
,而构建免安装应用时,它将 运行 和 AppFeat
。你可以玩这个的变体。
但是,如果您使用 isInstantApp() 分支,在一个应用程序实现中会更容易。
我可以为免安装应用程序和常规应用程序使用不同的清单吗?
更详细地说,我需要在 "android:name=App"
字段(应用程序标签)中指定不同的 类 "App"。
为了帮助您开始,这里是 github 关于免安装应用程序的示例代码。您可以检查以下代码的结构:
<!--
~ Copyright 2017 Google Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.instantapps.samples.hello.feature">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".HelloActivity"
android:label="@string/title_activity_hello">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:autoVerify="true"
android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="hello.instantappsample.com" />
<data android:pathPrefix="/hello" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://hello.instantappsample.com/hello" />
</activity>
<activity
android:name=".GoodbyeActivity"
android:label="@string/title_activity_goodbye">
<intent-filter
android:autoVerify="true"
android:order="2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="hello.instantappsample.com" />
<data android:pathPrefix="/goodbye" />
</intent-filter>
</activity>
</application>
</manifest>
这里是 Manifest file structure 可以帮助您在构建阶段进一步发展。
The code snippet below shows the general structure of the manifest file and every element that it can contain. Each element, along with all of its attributes, is fully documented in a separate file.
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<uses-permission />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />
<uses-feature />
<supports-screens />
<compatible-screens />
<supports-gl-texture />
<application>
<activity>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity>
<activity-alias>
<intent-filter> . . . </intent-filter>
<meta-data />
</activity-alias>
<service>
<intent-filter> . . . </intent-filter>
<meta-data/>
</service>
<receiver>
<intent-filter> . . . </intent-filter>
<meta-data />
</receiver>
<provider>
<grant-uri-permission />
<meta-data />
<path-permission />
</provider>
<uses-library />
</application>
</manifest>
有几种方法可以做到这一点:
如果您必须有两个不同的清单,那么您将需要使用 tools:replace
,示例:
您安装的应用程序模块的清单:
<application
android:name="com.example.App"
tools:replace="android:name"/>
您的功能模块清单:
<application
android:name="com.example.feature.AppFeat">
构建安装型应用时,它将 运行 和 App
,而构建免安装应用时,它将 运行 和 AppFeat
。你可以玩这个的变体。
但是,如果您使用 isInstantApp() 分支,在一个应用程序实现中会更容易。