tengo un problema tengo esta clase
public class Class_Session {
private String idAgente = "";
private double Lat = 0;
private double Lon = 0;
public String getIdAgente() {
return idAgente;
}
public void setIdAgente(String idAgente) {
this.idAgente = idAgente;
}
public Double getLat() {
return Lat;
}
public void setLat(Double lat) {
Lat = lat;
}
public Double getLon() {
return Lon;
}
public void setLon(Double lon) {
Lon = lon;
}
}
La utilizo para crear un objeto que guarde la latitud y longitud mediante esta otra clase
Class_Session session = new Class_Session();
double lg, lt;
LocationManager locationManager;
public class LoginActivity {
public void LocationStart() {
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
final boolean GPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if(!GPSEnabled) {
Intent configGPS = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(configGPS);
}
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 00, locationListenerGPS);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 2 * 20 * 1000, 10, locationListenerGPS);
}
private final LocationListener locationListenerGPS = new LocationListener() {
public void onLocationChanged(Location location) {
lg = location.getLongitude();
lt = location.getLatitude();
runOnUiThread(new Runnable() {
@Override
public void run() {
//Toast.makeText(LoginActivity.this, "GPS Provider update", Toast.LENGTH_SHORT).show();
session.setLat(lt);
session.setLon(lg);
}
});
}
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override
public void onProviderEnabled(String s) {
}
@Override
public void onProviderDisabled(String s) {
}
};
}
Una vez me cambio de actividad no puedo llevarme la inflacionario del objeto porque esta instanciado en la otra activity y si instancio uno nuevo perderé la ubicación. Que solución es factible ?