即时应用程序的单独清单
答
有几个方法可以做到这一点:
如果你必须有两个不同的体现,那么你将需要使用tools:replace
,例如:
你的安装,应用程序模块的清单:
<application
android:name="com.example.App"
tools:replace="android:name"/>
你的功能模块的清单:
<application
android:name="com.example.feature.AppFeat">
当您安装的应用程序被构建时,它将以App
运行,并且当您的即时应用程序被构建时,它将以AppFeat
运行。你可以玩这个变化。
但是,如果您使用InstantApps.isInstantApp()
来分支,只需一个应用程序实现,那将更容易。 https://developer.android.com/topic/instant-apps/reference.html#isinstantapp
答
为了帮助您入门,以下是来自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帮助您进一步在构建阶段。
以下代码片段显示清单 文件及其可包含的每个元素的一般结构。每个元素和 的所有属性都完全记录在一个单独的文件中。
<?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>
+0
)谢谢,我知道结构,但这不是我的问题的答案 – Dast6Tino
您的意思是应用程序模块包含一个'android:name =“App”',当它是一个已安装的应用程序时,它将覆盖功能模块的'android:name =“AppFeat”? – TWL
@TWL是的,正常的应用程序是工作,但即时工作只有调试版本( – Dast6Tino