我的 Android 应用程序无法通过链接打开,尽管我的清单应该指示它

问题描述 投票:0回答:1

我有一个 android 应用程序,它应该在类似

的链接上方打开自己

https://example.com/copyPOI/?ID=613a558o3f8ba

我的 Android 清单是:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

<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"
    android:usesCleartextTraffic="false">

    <activity android:name=".Help" />
    <activity android:name=".Orte" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">

        <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="example.com"
                android:pathPrefix="/copyPOI/" />

            <data
                android:scheme="https"
                android:host="www.example.com"
                android:pathPrefix="/copyPOI/" />
            <data
                android:scheme="http"
                android:host="example.com"
                android:pathPrefix="/copyPOI/" />

            <data
                android:scheme="http"
                android:host="www.example.com"
                android:pathPrefix="/copyPOI/" />                

        </intent-filter>
    </activity>
</application>

我的主要活动是:

    // Get the intent that started this activity
// Falls die App über einen Link aufgerufen wurde, wird dieser hier verarbeitet
        Intent intent = getIntent();
        Uri data = intent.getData();
        if (data != null) {     // bei null wurde die App ganz normal über den Launcher aufgerufen
            // Log-Ausgabe für Debugging-Zwecke hinzufügen
            Log.d("MainActivity", "App opened with link. URI: " + data);

            // Eintrag des zu kopierenden Links in die db
            copyLink(data);
        } else {
            // Log-Ausgabe für Debugging-Zwecke hinzufügen
            Log.d("MainActivity", "App opened without link.");

            make_refresh();
        }

但是我的浏览器没有打开我的应用程序,而是获取该链接并想要打开它。

有人看到这里出了什么问题吗? 我用的是安卓14。

预先感谢您的帮助。

android android-studio android-manifest
1个回答
0
投票

发生这种情况是由于 Android 12 中的行为更改

对于您的测试案例,看起来手动验证是测试其工作原理的最简单方法。但如果您需要此逻辑进行生产并拥有自定义域,则需要 添加应用程序链接

© www.soinside.com 2019 - 2024. All rights reserved.