意图过滤器数据路径中的哈希符号
Hash symbol in intent-filter data path
这是我的一部分 AndroidMaifest.xml
:
<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="http" />
<data android:scheme="https" />
<data android:host="myhost.com" />
</intent-filter>
现在我想用我的应用程序打开以下链接:
myhost.com/my/path
和 myhost.com/my/#/path
。它们都在应用程序中打开,但对于第一个 getIntent().getData().getPath()
returns /my/path
(这是正确的),但对于第二个它 returns /my
(其中它应该是 /my/#/path
)。我是不是想错了,或者 #
被窃听并切断了路径?
答案在这里。而不是
Uri uri = getIntent().getData()
我现在用
String uriString = Uri.encode(getIntent().getDataString(), "/:?&="); // I'm not sure if those are all characters that should be allowed
Uri uri = Uri.parse(uriString);
希望对大家有所帮助!
这是我的一部分 AndroidMaifest.xml
:
<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="http" />
<data android:scheme="https" />
<data android:host="myhost.com" />
</intent-filter>
现在我想用我的应用程序打开以下链接:
myhost.com/my/path
和 myhost.com/my/#/path
。它们都在应用程序中打开,但对于第一个 getIntent().getData().getPath()
returns /my/path
(这是正确的),但对于第二个它 returns /my
(其中它应该是 /my/#/path
)。我是不是想错了,或者 #
被窃听并切断了路径?
答案在这里。而不是
Uri uri = getIntent().getData()
我现在用
String uriString = Uri.encode(getIntent().getDataString(), "/:?&="); // I'm not sure if those are all characters that should be allowed
Uri uri = Uri.parse(uriString);
希望对大家有所帮助!