I'm using different processes (using android:process in my manifest) to be able to use more than one mapView in my app (How to use multiple MapActivities/MapViews per Android application/process). The 2 maps are in different activities and different tabs of my general tabhost.
No I want to zoom to a specific location, which is selected through the user in an other activity. Using static variables didn't work. After that I've tried to save the data in to a SharedPreferences file and read it again in the MapActivity. But this also don't work. The datas are written successfully, but the MapActivity does not find any data in the SharedPreferences.
Is there a possibility to share data between two or more processes?
Saving location data:
public static boolean addLocationToShared(float lat, float lon){
Log.i(TAG, "addLocationToShared: " + lat + "," + lon);
if(mapShared==null)
mapShared = TLApplication.getAppContext().getSharedPreferences(MAP_SHARED_PREFS, Context.MODE_PRIVATE);
return mapShared.edit().putFloat(PREF_LAT, lat).putFloat(PREF_LON, lon).commit();
}
Reading location data:
mapShared = TLApplication.getAppContext().getSharedPreferences(MAP_SHARED_PREFS, Context.MODE_PRIVATE);
float lat = mapShared.getFloat(PREF_LAT, 1000);
float lon = mapShared.getFloat(PREF_LON, 1000);
Log.d(TAG, "zoom to " + lat + ", " + lon);
if(lat != 1000 && lon != 1000){
GeoPoint point = new GeoPoint((int)(lat * 1E6), (int)(lon * 1E6));
zoomToLocation(point, 15);
}