Please teach me how to transfer data between activities

Asked 2 years ago, Updated 2 years ago, 156 views

What I thought is that if there is a login page, you log in and there is a logout button for each activity. So, when I press logout, I want to pass the logged out or logged in session ID to another activity, what should I do? Or is there any other solution other than delivering session ID?

android android-intent

2022-09-22 15:47

1 Answers

I think it would be easiest to deliver the session ID. I think we can deliver the logout activity to the intent.

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

Like this. And receiving the intents delivered is

Bundle extras = getIntent().getExtras();
if (extras != null) {
    String value = extras.getString("EXTRA_SESSION_ID");
}

This is how you do it


2022-09-22 15:47

If you have any answers or tips

Popular Tags
python x 4647
android x 1593
java x 1494
javascript x 1427
c x 927
c++ x 878
ruby-on-rails x 696
php x 692
python3 x 685
html x 656

© 2024 OneMinuteCode. All rights reserved.