我正在使用新的Google API检索当前位置,并获取了当前位置。但是,如果位置服务默认情况下未在应用程序中启用,并且如果我使用位置意向启用任何位置服务,则客户端不会在onActivityResult
方法中重新连接,并且我无法获取当前位置。使用Google Play服务检索用户当前位置
public void onConnected(Bundle bundle) {
// TODO Auto-generated method stub
System.out.println(R.string.connected);
System.out.println("error");
startPeriodicUpdates();
if (mUpdatesRequested) {
startPeriodicUpdates();
}
if (!locationServiceEnabled)
return;
if(mLocationClient.isConnected()&& servicesConnected())
{
fetchlocation = new FetchingLocation(getActivity());
// mLocationClient = new LocationClient(getActivity(), this,this);
Location currentLocation = mLocationClient.getLastLocation();
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>" +
mLocationClient.getLastLocation());
latitude=currentLocation.getLatitude();
System.out.println(currentLocation.getLatitude());
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
+ String.valueOf(latitude));
}
else
{
}
}
但我无法获取位置。随着应用程序崩溃,它显示错误:
client not connected wait for connect
有关如何解决此问题的任何想法?
我的实际isuue是,如果能像意图意图位置服务=新意图( \t \t \t \t \t \t Settings.ACTION_LOCATION_SOURCE_SETTINGS); \t \t \t \t startActivityForResult(intent,1);在我回到应用程序onActivity结果canot获取位置后,由于位置客户端没有连接。当尝试重新连接但没有使用 – RAHULRSANNIDHI