android twitter4j回调调用主要活动

时间:2011-11-21 13:10:55

标签: android android-activity callback 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");
    }

1 个答案:

答案 0 :(得分:1)

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

  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;