我正在 Android 手机上进行身份验证,该手机在单击登录按钮后将用户发送到 Hunch 进行身份验证。这将设置一个新的 Intent ,如下所示:
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);
这是我的 list 文件
<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/?auth_token_key=4d3d3d3d3&user_id=hn_5678&next=%2F
您应该监视 ACTION_VIEW Intent 的 URL 更改,从 URL 中提取 auth_token_key
,然后使用 get-auth-token 将其交换为 auth_token
API 调用。
关于java - Android 手机重定向上的 Hunch 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5638575/