How to return back to previous activity ?

  • Replies:1
  • Forum posts: 1

Nov 20, 2013, 4:20:58 PM via Website

I am new to Android development, hence kindly forgive any unintentional mistakes, if made.

I have a native activity rendering using ES2.0. The app needs to start twitter authentication (it uses twitter4j).

I am starting a new activity with twitter auth url. It shows the login page. I give userId, password, the native browser says now it would be redirected to the previous page or something. Then I see a black screen which apparently is the default browser still on top of the application. If I go to home, and background processes, I see my app and the browser as separate activities which makes sense.

Now my question is , how do I code my app to return back to the application once the authentication ends?

Here is the code flow to start the new activity

1. Native code calls JNI function to start authorization
2. The Java function creates an AsyncTask, in doInBackground() it gets the request token using getOAuthRequestToken(URL) where URL = custom url "app1://callback".
3. in onPostExecute() , app starts new intent activity using this code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL()));
Log.debug("authenticate task post ends");