android twitter4j回调调用主要活动
Twitter 回调将我返回到主活动而不是 TwitterActivity,这是我的代码。请问有什么建议吗?
这是我的清单:
<activity android:name=".TwitterActivity" android:launchMode="singleInstance">
<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="twitter-callback" />
</intent-filter>
</activity>
这是我的代码:
private static final String CALLBACK_URL = "twitter-callback:///";
// Some code
private void dealWithTwitterResponse(Intent intent) {
Uri uri = intent.getData();
if (uri != null && uri.toString().startsWith(CALLBACK_URL)) { // If the user has just logged in
String oauthVerifier = uri.getQueryParameter("oauth_verifier");
authoriseNewUser(oauthVerifier);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.i(TAG, "New Intent Arrived");
dealWithTwitterResponse(intent);
}
@Override
protected void onResume() {
super.onResume();
Log.i(TAG, "Arrived at onResume");
}
Twitter callback returns me to the main activity and not to the TwitterActivity, here is my code. Any suggestions please?
This is my manifest:
<activity android:name=".TwitterActivity" android:launchMode="singleInstance">
<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="twitter-callback" />
</intent-filter>
</activity>
This is my code:
private static final String CALLBACK_URL = "twitter-callback:///";
// Some code
private void dealWithTwitterResponse(Intent intent) {
Uri uri = intent.getData();
if (uri != null && uri.toString().startsWith(CALLBACK_URL)) { // If the user has just logged in
String oauthVerifier = uri.getQueryParameter("oauth_verifier");
authoriseNewUser(oauthVerifier);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.i(TAG, "New Intent Arrived");
dealWithTwitterResponse(intent);
}
@Override
protected void onResume() {
super.onResume();
Log.i(TAG, "Arrived at onResume");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以试试这个回调网址。
You can try this callback url.