I'm still relatively new to Android. I'm working on a map based app and want to incorporate an old map fragment and inflate it into a new activity.
In terms of the intent, I only want to send a double latitude and double longitude to the new activity and I have written some code to work from those values alone.
But I want the transition between activities to be seamless (with a few button additions. I don't want to make new fragments if I don't have to.
My onCreate method in the starting activity is like so:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map_activity);
mapFragment.getMapAsync(this);
}
and there is a button in which the onClick method sends the LatLng doubles to a new Activity. The onCreate for the second activity is the following:
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_circle_size);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map_activity);
mapFragment.getMapAsync(this);
double latitude = this.getIntent().getDoubleExtra("SEND_LATITUDE", 0);
double longitude = this.getIntent().getDoubleExtra("SEND_LONGITUDE", 0);
circleSize(latitude, longitude);
}
As you can see, I'm trying to use the same fragment from the layout with SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map_activity);
Do I have the correct approach here?
Thank you
-T