Reputation: 3056
I need to start an Activity with parameters. I know i can do it with Intents and Bundles, but as far as i know it's only possible with String, boolean, etc...
I have to do it with custom parameters, like user-made classes.
For example, i got PLC-class in main activity, which contains many variables and methods, and i need to use it in the other activity.
I know the "public static" method, but i'm not a fan of it, and i'm sure i can find something else that fits my need.
I hope you guys can help me Bye
Upvotes: 0
Views: 656
Reputation: 1645
In my opinion you can make bean class... which have getter/setter method.. you can set value there, and retrieve those values in any other Activities.Using it class.
E.g
public class Constants{
public static Bean userBeen=new Bean();
}
Main activity
Constants.userBeen.setValue("anything");
In other Activity,, you can get value using userBeenobj;
Other Activity
String s=Constants.userBeen.getValue();
Hope this helps to you. I mostly use this.!
Upvotes: 0
Reputation: 1242
Or you can make your class implementing parcelable interface, and put it in a parcel that you send from your source activity to destination activity..
Upvotes: 1
Reputation: 3027
make your custom made class serializable and then put it in bundle like this
bundle.putSerializable(key, value);
Upvotes: 0