Reputation: 11427
I want to send an sms message containing current location of user. How do I make the sending function wait till the location is calculated?
Upvotes: 1
Views: 1271
Reputation: 20946
private class DeafLocationListener implements LocationListener {
private final String provider;
public DeafLocationListener(String provider) { this.provider = provider; }
@Override public void onLocationChanged(Location location) {
Log.d(TAG, String.format("onLocationChanged triggered (%s)", provider));
// SEND SMS HERE
}
@Override public void onProviderDisabled(String provider) { /*nop*/ }
@Override public void onProviderEnabled(String provider) { /*nop*/ }
@Override public void onStatusChanged(String provider, int status, Bundle extras) { /*nop*/ }
}
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTimeGPS, minDistanceGPS, new DeafLocationListener("GPS"););
Upvotes: 0