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

uurity8g  于 2024-01-04  发布在  Android
关注(0)|答案(1)|浏览(255)

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

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

字符串

  1. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  2. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  3. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  4. <uses-permission android:name="android.permission.INTERNET" />
  5. <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  6. <application
  7. android:allowBackup="true"
  8. android:icon="@mipmap/ic_launcher"
  9. android:label="@string/app_name"
  10. android:roundIcon="@mipmap/ic_launcher_round"
  11. android:supportsRtl="true"
  12. android:theme="@style/AppTheme"
  13. android:usesCleartextTraffic="false">
  14. <activity android:name=".Help" />
  15. <activity android:name=".Orte" />
  16. <activity
  17. android:name=".MainActivity"
  18. android:label="@string/app_name"
  19. android:theme="@style/AppTheme.NoActionBar">
  20. <intent-filter>
  21. <action android:name="android.intent.action.MAIN" />
  22. <category android:name="android.intent.category.LAUNCHER" />
  23. </intent-filter>
  24. <intent-filter>
  25. <action android:name="android.intent.action.VIEW" />
  26. <category android:name="android.intent.category.DEFAULT" />
  27. <category android:name="android.intent.category.BROWSABLE" />
  28. <data
  29. android:scheme="https"
  30. android:host="example.com"
  31. android:pathPrefix="/copyPOI/" />
  32. <data
  33. android:scheme="https"
  34. android:host="www.example.com"
  35. android:pathPrefix="/copyPOI/" />
  36. <data
  37. android:scheme="http"
  38. android:host="example.com"
  39. android:pathPrefix="/copyPOI/" />
  40. <data
  41. android:scheme="http"
  42. android:host="www.example.com"
  43. android:pathPrefix="/copyPOI/" />
  44. </intent-filter>
  45. </activity>
  46. </application>


And my mainactivity mainactivity is about:

  1. // Get the intent that started this activity
  2. // Falls die App über einen Link aufgerufen wurde, wird dieser hier verarbeitet
  3. Intent intent = getIntent();
  4. Uri data = intent.getData();
  5. if (data != null) { // bei null wurde die App ganz normal über den Launcher aufgerufen
  6. // Log-Ausgabe für Debugging-Zwecke hinzufügen
  7. Log.d("MainActivity", "App opened with link. URI: " + data);
  8. // Eintrag des zu kopierenden Links in die db
  9. copyLink(data);
  10. } else {
  11. // Log-Ausgabe für Debugging-Zwecke hinzufügen
  12. Log.d("MainActivity", "App opened without link.");
  13. make_refresh();
  14. }


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

f3temu5u

f3temu5u1#

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

相关问题