Android http方案的意图过滤器

Dav*_*son 5 android android-manifest

我构建了一个需要 OAuth 的 Android 应用程序。使用由 Android 拦截的自定义方案回调,一切运行良好。雅虎似乎已经更改了目标帖子,现在雅虎不接受自定义方案。

我现在正在寻找可能的替代方法。我的第一次尝试是使用普通的 http 方案并修改我的意图过滤器以拦截新的 URL。我的 AndroidManifest.xml 中有以下内容:

  <intent-filter>
    <action android:name="android.intent.action.VIEW"></action> 
    <category android:name="android.intent.category.DEFAULT"></category> 
    <category android:name="android.intent.category.BROWSABLE"></category>
    <data android:host="www.test.com" android:scheme="http"></data> 
  </intent-filter>
Run Code Online (Sandbox Code Playgroud)

其中 www.test.com 将替换为我拥有的域名。它似乎 :

  • 当我点击页面上的链接时,会触发此过滤器。
  • 雅虎重定向不会触发它,浏览器会打开 www.test.com 网站
  • 当我在浏览器中直接输入域名时不会触发。

那么有人可以帮助我吗

  • 这个意图过滤器到底什么时候会被触发?
  • 对意图过滤器或权限进行的任何更改都会扩大过滤器以应用于重定向请求吗?
  • 我还可以使用其他方法吗?

感谢您的帮助。

Adr*_*nei 3

另一个解决方案怎么样,在您的 www.test.com 上放置一个提取 oauth 参数并重定向到您的自定义方案回调的脚本?

例如 oauth.php (请原谅我的 PHP ...)

<?
header('Location:myschema://mythost?oauth_verifier='.urlencode( $_GET['oauth_verifier']).
    '&oauth_token='.urlencode($_GET['oauth_token']));
die();
?>
Run Code Online (Sandbox Code Playgroud)

我成功地将它用于 Google OAuth,它对回调 URL 有相同的限制。