3

Update 23/9/2013

This question is outdated as the things mentioned below are 80% deprecated for now.


For my application there is one tab host with 5 different activities for 5 tabs. One of those is actually an activity group, which contain 4 child activities, and users can go back and fro for these child activities.

Now one of the child activities is used to post tweet. The OAUTH thing is fine. However I find that the callback cannot actually point back to the activity but the parent activity group or even the tab activity. I am not sure where does it points to but the outcome is that when the user authorize my twitter app, and return to the android app, the activity will be started all over and called onCreate instead of onResume or onNewIntent. This causes an infinity loop , asking the user to authenicate again and again. I have tried to add android:launch:singleInstance but this does not help.

If I do not start the activity as a child but a new activity, everything is fine.I can get back to onNewIntent and successfully post tweets. So I am quite sure the cause is activity group or tab activity.

I am actually not very familiar of how intent filter works under tab / activity group, can anyone explain the case for me?

Manifest.xml      
<activity android:name="TwitterAct" 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="myapp" android:host="twitteract" />       
        </intent-filter>
</activity>

TwitterAct
private final String CALLBACKURL = "myapp://twitteract"; 

Thanks

reTs
  • 1,808
  • 1
  • 13
  • 26

1 Answers1

0

I asked a similar question a while ago and got answers from a few folks:

Is there a production quality OAuth sample for Android?

I got mine routing the intent back to the original activity using singleTask instead of singleInstance, but it seems like folks have success both ways. Looks like most folks add the flags (Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND) when creating the Intent to launch the browser. Not exactly sure how those would interact with singleInstance, but might affect where the intent can get routed.

Community
  • 1
  • 1
mikerowehl
  • 2,222
  • 1
  • 17
  • 20
  • 1
    I had tried it and it works when I used a single intent. However the same method does not work for a child intent of an activity group. Anyway thanks. – reTs Jul 21 '11 at 04:20