在 Trusted Web Activity 中地址栏不隐藏
In Trusted Web Activity the address bar not hiding
在关注关于 TWA 的 Using Trusted Web Activities 页面并隐藏 URL 栏之后,我按照所有说明隐藏了 URL 栏,但令人惊讶的是它没有被隐藏。
我该如何解决这个问题?
这是我的 assetlinks.json 文件:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "org.foodeye.mobile",
"sha256_cert_fingerprints":
["BA:D3:3B:41:7C:1E:7B:DC:0F:FE:70:EB:33:5D:F1:A0:40:3B:09:73:A0:5D:42:80:45:DA:CB:DA:0F:9D:5A:D3"]
}
}]
这是 assetlinks.json url : https://foodeye.org/.well-known/assetlinks.json
这是清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.foodeye.mobile">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="asset_statements"
android:value="@string/asset_statements" />
<activity android:name="android.support.customtabs.trusted.LauncherActivity"
android:label="${launcherName}">
<meta-data android:name="android.support.customtabs.trusted.DEFAULT_URL"
android:value="${defaultUrl}" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"
android:host="${hostName}"/>
</intent-filter>
</activity>
</application>
这是 build.gradle 的应用程序:
apply plugin: 'com.android.application'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 28
defaultConfig {
applicationId "org.foodeye.mobile"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
hostName: "app.foodeye.org",
defaultUrl: "https://app.foodeye.org",
launcherName: "Food Eye",
assetStatements: '[{ "relation": ["delegate_permission/common.handle_all_urls"], ' +
'"target": {"namespace": "web", "site": "https://app.foodeye.org"}}]'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.GoogleChrome.custom-tabs-client:customtabs:d08e93fce3'
}
这是 strings.xml :
<resources>
<string name="app_name">Food Eye</string>
<string name="asset_statements">
[{
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://app.foodeye.org\"}
}]
</string>
提前致谢。
您在 TWA 中打开的 URL 似乎是 https://app.foodeye.org
,但资产链接托管在 https://foodeye.org/.well-known/assetlinks.json
,这是一个不同的来源。
您需要在与您在 TWA 中打开的 URL 相同的源上托管 assetlinks 文件。 https://app.foodeye.org/.well-known/assetlinks.json
在关注关于 TWA 的 Using Trusted Web Activities 页面并隐藏 URL 栏之后,我按照所有说明隐藏了 URL 栏,但令人惊讶的是它没有被隐藏。
我该如何解决这个问题?
这是我的 assetlinks.json 文件:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "org.foodeye.mobile",
"sha256_cert_fingerprints":
["BA:D3:3B:41:7C:1E:7B:DC:0F:FE:70:EB:33:5D:F1:A0:40:3B:09:73:A0:5D:42:80:45:DA:CB:DA:0F:9D:5A:D3"]
}
}]
这是 assetlinks.json url : https://foodeye.org/.well-known/assetlinks.json
这是清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.foodeye.mobile">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="asset_statements"
android:value="@string/asset_statements" />
<activity android:name="android.support.customtabs.trusted.LauncherActivity"
android:label="${launcherName}">
<meta-data android:name="android.support.customtabs.trusted.DEFAULT_URL"
android:value="${defaultUrl}" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"
android:host="${hostName}"/>
</intent-filter>
</activity>
</application>
这是 build.gradle 的应用程序:
apply plugin: 'com.android.application'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 28
defaultConfig {
applicationId "org.foodeye.mobile"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
hostName: "app.foodeye.org",
defaultUrl: "https://app.foodeye.org",
launcherName: "Food Eye",
assetStatements: '[{ "relation": ["delegate_permission/common.handle_all_urls"], ' +
'"target": {"namespace": "web", "site": "https://app.foodeye.org"}}]'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.GoogleChrome.custom-tabs-client:customtabs:d08e93fce3'
}
这是 strings.xml :
<resources>
<string name="app_name">Food Eye</string>
<string name="asset_statements">
[{
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://app.foodeye.org\"}
}]
</string>
提前致谢。
您在 TWA 中打开的 URL 似乎是 https://app.foodeye.org
,但资产链接托管在 https://foodeye.org/.well-known/assetlinks.json
,这是一个不同的来源。
您需要在与您在 TWA 中打开的 URL 相同的源上托管 assetlinks 文件。 https://app.foodeye.org/.well-known/assetlinks.json