1

My application has a list of clients (with only name and age displayed) and I want to be able to edit/add more info about them that is not visible in the list. So whenever I click on a client, I want to start a second activity with all the info about him.

Can I use an intent for this? Can I pass a full Object (Client) at once with an intent?

I've looked through these two topics, but I haven't found my answer yet:

How to exchange data (objects) between different Android Activities?

How do I pass data between Activities in Android application?

Thanks in advance.

3 Answers 3

1

Look at this answer: How to pass an object from one activity to another on Android

//to pass : intent.putExtra("MyClass", obj); // to retrieve object in second Activity getIntent().getSerializableExtra("MyClass"); 
Sign up to request clarification or add additional context in comments.

1 Comment

I get the "Cannot resolve method" error when I use putExtra() method. This is how I'm trying to send the intent: NewEntry client = ClientsList.get(position); Intent intent = new Intent(HomeActivity.this, ParseClient.class); intent.putExtra("MyClient", client); startActivity(intent); What am I doing wrong?
0

I would suggest you look into saving these in the SharedPreferences file. Build a singleton AppUtil class and add functionality to save data in the shared preferences there as well as being able to retrieve said data

If you have a large amount of information being stored for the clients then you should look into SQLite as database storage.

Comments

0

The more pratice way is create a class to hold every objects that you need to change between the activities. Like that:

public class MyHolderObjects { public static MyObjectType mObject; } 

before start the new activity (or whatever you goes to use it), instantiate (create) the object in MyHolderObjects. And use it everywhere you need :). I prefer this approach instead serialize the object.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.