Attempt to share objects between activities [SOLVED]

Put your problem here if it does not fit any of the other categories.

Attempt to share objects between activities [SOLVED]

Postby sandis84 » Mon Oct 26, 2009 10:30 am

Edit Warning: Problem solved, it was a typo in the code, lol.

I tried to share objects by having a global hashmap in my first activity, Activity1:

public static HashMap<String, Object> sharedObjects;

then in my second activity I run for example:


But I get a nullpointerexception.

Following other discussions Im getting the idea that this should work and be the best way to share objects, see for example: ... c47cc5bbd8

Obviously I am doing something wrong. The strange thing is that I can access the static hashmap from Activity1, but not from Activity2.

edit: LOL, i forgot to create the static object. It should ofcourse be:
public static HashMap<String, Object> sharedObjects = new HashMap<String, Object>();

Maybe this thread can still help people who are trying to share objects between activities, thought. =)
Experienced Developer
Experienced Developer
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 5 guests