I have an application that gets the user's location, now I need to send those values (latitude, longitude) when launching a service ..
//Variables donde se guardan las coordenadas
Double lati = new Double(0);
Double longi = new Double(0);
//Variables para convertir a String las coordenadas
public String latis = Double.toString(lati);
public String longis = Double.toString(longi);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Método para obtener la ubicación
locationStart();
// Se lanza el servicio
startService(new Intent(this, ServiceDemo.class));
}
How can I pass these variables?
I tried to get the location from the Service class, but it marked me error when casting to MainActivity. So I opted to go directly through the variables, but I still can not find any solution.