Is it possible to put an instance of android.location.Address with Intent to another activity?
Address current_location;
I mean, I am trying to put current_location directly with the intent by:
-
IntentName.putExtra("current_location",current_location); -
or indirectly by a bundle:
Bundle b = new Bundle(); b.put....("current_location",current_location); IntentName.put(b);
If none of the above strategy support “Address” then what should be the best approach to pass the Address instance to another activity?
If I declare,
public static Address current_location;
and try to access it from another activity then there is no guarantee that Android will hold current_location data. Or am I wrong?
In such situation, what approach should be followed?
You’ll want to pass it through as a parcelable. By looking at the API, I think they already conform to the standard.
Address
extends Object
implements Parcelable
https://developer.android.com/reference/android/location/Address.html
So to package it up and send it you would do:
Then to reassemble it in your activity you would do:
The key is simply the name you use to store the parcelable under.