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

uurity8g  于 5个月前  发布在  Android
关注(0)|答案(1)|浏览(72)

我有一个adroid应用程序,它应该打开自己上面的链接,如
https://example.com/copyPOI/?ID=613a558o3f8ba
我的android manifest是:

<?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>


And my mainactivity mainactivity is about:

// 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();
        }


但是我的Brouwser没有打开我的应用程序,而是得到了那个链接,并想打开它。
有没有人看到,这里出了什么问题?我用的是android 14。
提前感谢您的帮助。

f3temu5u

f3temu5u1#

这是由于Android 12中的行为变化。
对于您的 * 测试 * 案例,手动验证似乎是测试其工作原理的最简单方法。但如果您需要此逻辑用于生产并拥有自定义域,则需要添加App Links

相关问题