1
I have a service to get the user’s location, but I need to pass the latitude and longitude via request to a server, however I tried to make this request within the method onLocationChanged()
using Okhttpclient, but unsuccessfully.
Does anyone have any other hint of what I can do in this situation?
private class MyLocationListener implements LocationListener {
public void onLocationChanged(Location location) {
Context contexto = getApplicationContext();
int duracao = Toast.LENGTH_SHORT;com
Toast toast = Toast.makeText(contexto, "Latitude: " + location.getLatitude() + " Longitude: " + location.getLongitude(), duracao);
toast.show();
}
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override
public void onProviderEnabled(String s) {
}
@Override
public void onProviderDisabled(String s) {
}
}
as it is a service, I do thread on own service??
– SkullFire
I didn’t know it was a Service. Perhaps it is better to pass the latitude and longitude to a second Service responsible for making the request.
– Piovezan
This is new to me, If I can pass information from one service to another, do I do it within a service? I’m trying to give a research, but if you have some interesting content for me to look for, it would really help
– SkullFire
https://stackoverflow.com/q/29192767/2241463
– Piovezan
And if by kindness, I wanted the location passed to that second X service in X time?
– SkullFire
Then I would have to see the task scheduling feature of Android. I can’t remember why I’m rusty
– Piovezan