繁体   English   中英

android twitter4j回调调用主要活动

[英]android twitter4j callback calls main activity

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");
    }

您可以尝试使用此回调网址。

  public static final String    OAUTH_CALLBACK_SCHEME   = "x-oauthflow-twitter";
        public static final String  OAUTH_CALLBACK_HOST = "callback";
        public static final String  OAUTH_CALLBACK_URL  = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM