You can do something like this (where i've written the code from
memory and thus missed a lot of important stuff, no doubt):

public class MyApplication extends Application {
   SomeDataObject myDataObject;

   public static class SomeDataObject {
       String someString;
       int someInt;
   }

   public void onCreate() {
       myDataObject = new SomeDataObject();
       myDataObject.someString = "";
   }
}

public class ActivityA extends Activity {
   public void someFunction() {
       MyApplication.myDataObject.someString = "hello";
   }
}

public class ActivityB extends Activity {
   public void someFunction() {
       localString = MyApplication.myDataObject.someString;
   }
}

On Jul 4, 10:34 pm, Thomas Frick <[email protected]> wrote:
> Dear All,
>
> I have two activities.
> Activity A creates an object and stores some data in this object.
> After that, activity B ist started. In activity B I have to use the
> object created in activity A.
>
> What is the best way to pass the object from activity A to B?
>
> I think it is not possible to store an object in the
> SharedPreferences, isn't it?
>
> Is it a good way to call the object in activity A directly from
> activity B?
>
> Thanks for your help.
> Thomas

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to