UMAR UMAR - 4 months ago 5
Android Question

How do I pass data between activities on Android?

I have a scenario where, after logging in through a login page, there will be a sign out button on each activity.

On clicking signout, I will be passing the session id of the signed in user to signout. Can anyone guide me on how to keep session id available to all activities??

Alternatively, is there another solution to this problem?


The easiest way to do this would be to pass the session id to the signout activity in the intent you're using to start the activity:

Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("EXTRA_SESSION_ID", sessionId);

The docs for Intents has more information (look at the section titled "Extras").