Reputation: 8578
I am in process of writing an activity that shows a Google map, and by getting an extra value on the calling intent, placing some overlay on a given geopoint over the map.
What i did was to create a wrapping class to hold (lat,lng) pair and that implements Parcelable, this way i could pass a "geopoint" instance on an Intent to this activity from other activities in other applications.
now what that im stuck at is what should i put as the key value for putting and getting this geopoint?
i could just use it like:
i.putExtra("myGeoPoint", myGeoPoint);
but i am guessing that would be bad practice, I could have a final static String class-member object as the key value, but then i am not 100% sure that i could access it from other activities in other applications...
How is it done correctly?
Upvotes: 0
Views: 257
Reputation: 1007534
but i am guessing that would be bad practice
Well, it has to be a string.
I could have a final static String class-member object as the key value, but then i am not 100% sure that i could access it from other activities in other applications...
It is 100% certain that you cannot "access it from other activities in other applications".
Hence, use a well-known string. Each of those apps can, if desired, save that string in "a final static String class-member object" for its own local use. Or, you can create a small JAR file that all of these projects use that, perhaps among other things, provides a canonical "a final static String class-member object" for them all to refer to.
Upvotes: 2