Question

I have a simple app has two activities I can login to twitter from each activity but i want to redirect to activity that user logged in from

in manifest I can write this xml for each activity and when twitter redirect it will show screen to choose the activity but i want to redirect to activity from which user logged in

<activity
        android:name="ActivityA"
         >
        <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:host="MYAPP"
                android:scheme="oauth" />
        </intent-filter>
    </activity>
Was it helpful?

Solution

You can add another activity in the manifest

<activity
    android:name="ActivityA"
     >
    <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:host="MYAPP"
            android:scheme="oauth" />
    </intent-filter>
</activity>

<activity
    android:name="ActivityB"
     >
    <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:host="MYAPP2"
            android:scheme="oauth" />
    </intent-filter>
</activity>

When you call the authentication url, set a different callback url If you are using Twitter4J, this is what it will look like.

requestToken = twitter.getOAuthRequestToken("oauth/MYAPP");
authenticationUrl = requestToken.getAuthenticationURL();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authenticationUrl)));

in the second activity,

requestToken = twitter.getOAuthRequestToken("oauth/MYAPP2");
authenticationUrl = requestToken.getAuthenticationURL();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authenticationUrl)));

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top