我正在使用Android手机进行身份验证,该手机在单击登录按钮后会将用户发送到Hunch进行身份验证。这将建立一个新的意图,如下所示:

Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri data = Uri.parse("hunch.com/authorize/v1/?app_id=1234&next=hoosheer-hunch-app://");
    intent.setData(data);
    startActivity(intent);


这是我的清单文件

<activity android:name="hunch" android:label="hunch">
        <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="hoosheer-hunch-app" />
        </intent-filter>
    </activity>


它给了我这个错误:

04-12 17:04:22.574: ERROR/AndroidRuntime(838): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=hunch.com/authorize/v1/?app_id=1234&next=hoosheer-hunch-app:// }


但是我有类似的代码可用于使用Foursquare登录。 hunch.java类包含onResume方法

最佳答案

Hunch当前不支持自定义URL方案,例如hoosheer-hunch-app://

在我们实现此功能之前,您应该使用以下URL进行身份验证:


  http://hunch.com/authorize/v1/?app_id=1234&next=/


授权您的应用程序后,该用户将被重定向到


  http://hunch.com/?auth_token_key=4d3d3d3d3&user_id=hn_5678&next=%2F


您应该监视ACTION_VIEW Intent以了解URL的更改,将auth_token_key从URL中拉出,然后使用get-auth-token API调用将其替换为auth_token

关于java - Android手机重定向上的Hunch身份验证,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5638575/

10-10 13:43