views:

86

answers:

2

My application supports twitter and needs to open browser for OAuth. When the user clicks the Share on Twitter button, the main activity will create another subactivity (TwitterActivity) to handle twitter authentication issues.

Here is a flow graph showing how activities are invoked currently. Main is short for MainActivity and Twit for TwitterActivity.

     startActivity()       OAuth intent           OAuth callback       finish()
Main ---------------> Twit ------------> Browser  --------------> Twit --------> Browser

As you may notice, after the TwitterActivity calls finish() to stop, it will now return back to MainActivity, but Browser instead. How can I make it return back to MainActivity? Many thanks

+1  A: 

try setting the noHistory attribute for the Browser's activity to true in the Manifest.

jqpubliq
Thanks for your reply. Could you tell me how to set browser's attribute?
ZelluX
Just realized that by browser you meant the native client. Try starting the Browser with startActivityForResult(Intent, int) so that you can call finishActivity(int) from within Twit to close the browser before you call finish on the Twit activity itself. Docs [here](http://developer.android.com/reference/android/app/Activity.html)
jqpubliq
+1  A: 

You could consider switching to browserless xAuth authentication method. It provides much more user friendly experience http://apiwiki.twitter.com/Twitter-REST-API-Method:-oauth-access_token-for-xAuth.

Fedor