Android的意图过滤器http方案 [英] Android intent-filter for http scheme

查看:122
本文介绍了Android的意图过滤器http方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个Android应用程序,需要的OAuth。一切都运作良好使用通过截获的Andr​​oid定制方案回调。看来,雅虎已经改变了球门柱现在的自定义方案不接受雅虎。

I built an Android application that requires OAuth. All was working well using a custom scheme call back which is intercepted by Android. It seems that Yahoo have changed the goal posts and now the custom scheme is not accepted by Yahoo.

我现在在看可能的替代办法。我的第一次尝试是使用一个普通的HTTP方案和修改我的意图过滤器拦截新的URL。我有以下的在我的Andr​​oidManifest.xml:

I am now looking at possible alternate approaches. My first attempt is to use a normal http scheme and modify my intent filter to intercept the new URL. I have the following in my 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将被替换为我自己的域名。看来:

Where www.test.com will be substituted with a domain that I own. It seems :

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

所以,任何人可以帮助我,

So can anybody help me with

  • 在当前正是这种意图过滤器将被触发?
  • 如有任何更改,意图过滤器或权限将扩大过滤器适用于请求重定向?
  • 在任何其他的方法,我可以用?

感谢您的帮助。

推荐答案

如何替代解决方案,将在您的www.test.com提取OAuth的参数和重定向到您的自定义方案的回调?脚本

How about an alternative solution, placing on your www.test.com a script that extracts the oauth parameters and redirects to your custom scheme callback?

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

Such as for instance oauth.php (pardon my PHP ...)

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

我成功地用它为谷歌的OAuth这对回调URL相同的限制。

I am succesfully using it for Google OAuth which has the same restriction on the callback URL.

这篇关于Android的意图过滤器http方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆