我想构建一个应用程序,它将使用cellular Network
和提供当前位置WiFi
。
我喜欢同时从两个提供商那里获取位置,然后决定哪个提供商给我最好的。
现在我从网络获取位置
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener locationlistenerforNetwork = new mylocationlistenerNetwork();
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationlistenerforNetwork);
private class mylocationlistenerNetwork implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Log.d("LOCATION CHANGED", location.getLatitude() + " ");
Log.d("LOCATION CHANGED", location.getLongitude() + " ");
Toast.makeText(LocationActivity.this,"latitude: "+
location.getLatitude() + "longitude: " + location.getLongitude()
+ " Provider:" + location.getProvider() + " Accuracy:" + location.getAccuracy(),
Toast.LENGTH_LONG).show();
}
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
我也想从WiFi
. 请帮忙。