android - Create a common object for whole Application -
i have created 1 activity creates user profile , stores info name,id, profile pic etc.
this info unique , should utilize in activities in application.
i want know best way create mutual object stores info , utilize in activities.
i have read bundle , json can't understand how utilize it.
please help me alternative should choose. have done lot of reading not sure of now. please help me whats standard thing , better.
you can utilize application
class accessing same object across many activities.
public class testapplication extends application { //object declaration public testapplication () { // todo auto-generated constructor stub } @override public void oncreate() { // todo auto-generated method stub super.oncreate(); } //setter getter object }
now in activity:
//after setcontentview testapplication testappobj = (testapplication) getapplication(); testappobj.setsomeobj(myobj); //retrieve as: someobj = testappobj.gettermethodofobj();
you must register application class in manifest file register activities:
<application android:name="com.pkg.test.testapplication " />
hope helps.
android object android-activity android-json
No comments:
Post a Comment