I'm using Twitter4J to authorise with Twitter from an activity which is not the application's launch activity. So far I have a separate activity called 'AuthorisationActivity' which returns an intent with a valid Twitter4j twitter object which then can be used by the calling activity 'CallAuthorisationActivity'.
The callback from twitter works fine and I end up with an authorised twitter object in AuthorisationActivity, but now I find myself in a catch22 situation:
1 - If I DON'T set the AuthorisationActivity's Launch mode to 'singleTask', the callback will not return to AuthorisationActivity's onNewIntent() method, but to its onCreate() method and try to authenticate in an endless loop.
2 - If I DO set the AuthorisationActivity's Launch mode to 'singleTask', it will return to onNewIntent() but since it now is in a separate task, it will not return to the calling activity's onActivityResult() method.
I'm only a beginner in Android development, and since the authentication works, I assume that this problem has more to do with how the activites are managed. Below is a simplified excerpt from the manifest:
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CallAuthorisationActivity">
</activity>
<activity
android:name=".AuthorisationActivity"
android:label="@string/title_activity_authorisation">
<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="tweetree" android:host="callback" />
</intent-filter>
</activity>
In the code, CallAuthorisationActivity just sends an intent with startActivityForResult(...) to AuthorisationActivity and catches the result in onActivityResult(...) as is standard. Any help would be appreciated, thanks