android twitter4j 誓言回调选项卡
我有一个 tabActivity (.Tabs),其中一个选项卡具有 Twitter 集成 (.TwitterTab)。在该选项卡中,您可以单击按钮登录 Twitter。一旦您在其移动门户网站上使用 twitter 进行身份验证,您就会返回到应用程序...但它会转到 twitter 活动 (.TwitterTab),而不是选项卡活动 (.Tabs)。
如何让它返回到 .Tabs 并选择 .TwitterTab 选项卡?
<activity android:name=".service.oath.PrepareRequestTokenActivity" android:launchMode="singleTask">>
<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="x-oauthflow-twitter" android:host="callback" />
</intent-filter>
</activity>
I have a tabActivity (.Tabs) in which one of the tabs has twitter integration (.TwitterTab). From that tab, you can click a button to login to twitter. Once you authenticate with twitter on their mobile web portal, you are returned back to the app... but it goes to the twitter activity (.TwitterTab), NOT the tab activity (.Tabs).
How can i make it return to the .Tabs with the .TwitterTab tab selected?
<activity android:name=".service.oath.PrepareRequestTokenActivity" android:launchMode="singleTask">>
<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="x-oauthflow-twitter" android:host="callback" />
</intent-filter>
</activity>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在Android清单中为某个活动设置Scheme和Host时,它会告诉Android所有涉及该特定Scheme和Host的请求都应该由该活动处理。
当您使用 oAuth 和 Twitter4j 进行身份验证时,您必须提供在身份验证完成后使用的回调 URL。根据上面的清单摘录,您的清单将类似于:
x-oauthflow-twitter://callback
。当身份验证过程完成后,android 被告知去处理您提供的回调的活动。 (在您的情况下,.service.oath.PrepareRequestTokenActivity)因此,为您的 tabActivity 设置方案和主机,以便 android 在身份验证后返回那里,并覆盖 onResume 来处理返回。我确信一旦达到这一点,就有一种编程方式可以打开 Twitter 选项卡。
您可以查看这篇文章以获取有关scheme/host和twitter4j身份验证的更多示例。
When you set Scheme and Host for an activity in the Android Manifest, it tells android that all requests involving that particular Scheme and Host should be handled by that activity.
When you are authenticating using oAuth and Twitter4j, you have to provide a callback URL that is used once authentication is complete. According to your manifest excerpt above, yours would be something like:
x-oauthflow-twitter://callback
. When the authentication process is finished, android is told to go to the activity that handles the callback you provided. (In your case, .service.oath.PrepareRequestTokenActivity)So, set the scheme and host for your tabActivity so that android goes back there after authenticating, and override onResume to handle the return. I'm sure there is a programmatic way to have the Twitter tab opened once you get to that point.
You can check out this post for more examples on scheme/host and twitter4j authenticating.