简体   繁体   中英

android twitter4j oath callback to tab

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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