【问题标题】:Android intent-filter for http scheme用于 http 方案的 Android 意图过滤器
【发布时间】:2011-04-12 05:23:36
【问题描述】:

我构建了一个需要 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>

www.test.com 将替换为我拥有的域。看来:

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

谁能帮帮我

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

感谢您的帮助。

【问题讨论】:

  • 哦,不,我目前有完全相同的问题,所以我真的必须创建一个重定向脚本吗?必须有更好的解决方案..

标签: android android-manifest


【解决方案1】:

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

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

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

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

【讨论】:

  • 谢谢。这也是我最后使用的方法。它很笨重,但它有效。在这个过程中增加一个额外的跳跃只是令人沮丧。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-14
  • 1970-01-01
  • 1970-01-01
  • 2015-04-08
  • 2017-05-30
  • 2015-07-14
相关资源
最近更新 更多