Skip to content
Advertisement

How do I pass ArrayLists to another activity, modify it, and return it back to use?

I’m trying to create a login/register part of a project, and I’m having trouble with passing the sign-up information back to the login activity. I initialized username_info, password_info, and name_info in MainActivity, and I want to send it to SignUpActivity through Intent.

JavaScript

After values are added in the other activity, it’s sent back like this (the arraylists have the same name in both activities):

JavaScript

and it’s received here:

JavaScript

But the array lists are unchanged when I get back to the MainActivity. I’m new to Android Studio, so I might just be making a simple mistake.

EDIT: I’m crashing when the username and password don’t match, but it should be returning a toast instead:

JavaScript

Advertisement

Answer

Don’t use getIntent() in onActivityResult, instead use the Intent data:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement