我想发送包含用户当前位置的短信。如何使发送功能等到计算位置?
答案 0 :(得分:1)
了解intents,您会发现。诀窍在于获取位置时发出意图。
答案 1 :(得分:0)
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"););