google maps - Android send value from Fragment to an activity -
hello guys have fragment activity shows google map , want send latitude , longitude values 1 of activities. how can except putextra. can't use putextra because can't startactivity after data complete. have bottomnavigation activity shows map fragment , settings activity in fragment too. , want collect data map fragment , use in second fragment. thanks.
you can use shared preference that.
example:
put value inside shared preference in fragment activity.
sharedpreferences sharedpref = getactivity().getpreferences(context.mode_private); sharedpreferences.editor editor = sharedpref.edit(); editor.putdouble("latitude", latitude); editor.putdouble("longitude", longitude); editor.apply();
get value shared preference in second activity.
sharedpreferences sharedpref = getactivity().getpreferences(context.mode_private); double latitude = sharedpref.getdouble("latitude"); double longitude = sharedpref.getdouble("longitude");
hope helps:)
Comments
Post a Comment