自定义 Android URI
Custom Android URI
我在这里阅读了几篇自定义 URI 帖子并尝试创建一个有效的 URI 方案。但是,它不起作用。 XML 的代码如下:
<activity android:name="testhing.ResetPasswordActivity"
android:label="@string/title_activity_reset_password"
android:parentActivityName="testthing.LoginActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="restthing.LoginActivity" />
<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="TESTTHING" android:host="ForgottenPassword" />
</intent-filter>
</activity>
如果我尝试在浏览器中导航至 'TESTHING://ForgottenPassword',它会运行 google 搜索但不会打开视图。我在 'TESTHING://ForgottenPassword?token=12345' 的电子邮件中有一个 link,但是这个 link 甚至没有显示为可点击。它就像自定义 URI 方案未注册一样。我的语法有问题吗?
If I attempt to navigate to 'TESTHING://ForgottenPassword' in the browser, it runs a google search but does not open the view.
Android 有很多浏览器。当您在地址栏中输入时,有些人可能会尝试使用 PackageManager
来查看这个随机字符系列是否恰好是 ACTION_VIEW
activity 的 Uri
。不要求浏览器执行此操作。
I have a link in an email that is 'TESTHING://ForgottenPassword?token=12345', but this link doesn't even show as clickable.
Android 有很多电子邮件客户端。理想情况下,电子邮件客户端在看到 link 时至少会尝试使用 link 声称要 link 的任何内容进行 ACTION_VIEW
操作。再次声明,不需要电子邮件客户端执行此操作。
Is there something wrong in my syntax?
我建议您的方案和主机全部使用小写字母。例如,您的电子邮件客户端可能正在应用采用小写方案的正则表达式,因为这是编写 URI 方案的正常方式。
总的来说,自定义方案在 Android 上只有一个赎回价值:它们不太可能与其他任何东西发生冲突并触发选择器。如果您使用 http
作为方案,并采用 "this app handles these URLs" 方法,您更有可能让应用程序识别您的 link。不过现在,这将触发一个选择器,用户可以在其中选择浏览器或您的应用程序。这就是为什么在 Android M 中,他们增加了在服务器上提供证据的能力,证明你 "own" URL 并且你希望这些 link 直接开车到你的应用程序并绕过选择器。
我在这里阅读了几篇自定义 URI 帖子并尝试创建一个有效的 URI 方案。但是,它不起作用。 XML 的代码如下:
<activity android:name="testhing.ResetPasswordActivity"
android:label="@string/title_activity_reset_password"
android:parentActivityName="testthing.LoginActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="restthing.LoginActivity" />
<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="TESTTHING" android:host="ForgottenPassword" />
</intent-filter>
</activity>
如果我尝试在浏览器中导航至 'TESTHING://ForgottenPassword',它会运行 google 搜索但不会打开视图。我在 'TESTHING://ForgottenPassword?token=12345' 的电子邮件中有一个 link,但是这个 link 甚至没有显示为可点击。它就像自定义 URI 方案未注册一样。我的语法有问题吗?
If I attempt to navigate to 'TESTHING://ForgottenPassword' in the browser, it runs a google search but does not open the view.
Android 有很多浏览器。当您在地址栏中输入时,有些人可能会尝试使用 PackageManager
来查看这个随机字符系列是否恰好是 ACTION_VIEW
activity 的 Uri
。不要求浏览器执行此操作。
I have a link in an email that is 'TESTHING://ForgottenPassword?token=12345', but this link doesn't even show as clickable.
Android 有很多电子邮件客户端。理想情况下,电子邮件客户端在看到 link 时至少会尝试使用 link 声称要 link 的任何内容进行 ACTION_VIEW
操作。再次声明,不需要电子邮件客户端执行此操作。
Is there something wrong in my syntax?
我建议您的方案和主机全部使用小写字母。例如,您的电子邮件客户端可能正在应用采用小写方案的正则表达式,因为这是编写 URI 方案的正常方式。
总的来说,自定义方案在 Android 上只有一个赎回价值:它们不太可能与其他任何东西发生冲突并触发选择器。如果您使用 http
作为方案,并采用 "this app handles these URLs" 方法,您更有可能让应用程序识别您的 link。不过现在,这将触发一个选择器,用户可以在其中选择浏览器或您的应用程序。这就是为什么在 Android M 中,他们增加了在服务器上提供证据的能力,证明你 "own" URL 并且你希望这些 link 直接开车到你的应用程序并绕过选择器。