How to pass a String from one method to another

0

Sorry I'm a novice in this, I need to pass a string from one method to another

The string I try to pass is called (bd_lat)

protected void onCreate(Bundle savedInstanceState) {

String bd_lat = object.getString("latitude");

}

This is the method where I must pass it

@Override
    public void onMapReady(GoogleMap googleMap) {

LatLng Bello = new LatLng(PONER ACA STRING bd_lat, -75.5580);

}
    
asked by Andres Arango 14.01.2018 в 05:33
source

1 answer

1

Create the bd_lat String as a Global variable. To do this, simply declare the variable outside the onCreate method like this:

Double bd_lat;
protected void onCreate(Bundle savedInstanceState) {
    bd_lat = Double.parseDouble(object.getString("latitude"));
}

@Override
    public void onMapReady(GoogleMap googleMap) {

LatLng Bello = new LatLng(bd_lat, -75.5580);

}

So you can use it wherever you want in that class.

    
answered by 14.01.2018 / 05:45
source