-1
我正在使用GooglePlayServices API
获取当前位置。在广播接收器中获取位置
在任何活动来获取当前位置下面的代码工作完美
@Override
protected void onStart() {
super.onStart();
// Connect the client.
mLocationClient.connect();
}
@Override
protected void onStop() {
// Disconnecting the client invalidates it.
mLocationClient.disconnect();
super.onStop();
}
和下面的代码给我的用户的最佳的最后已知位置。
mCurrentLocation = mLocationClient.getLastLocation();
但如何从理想位置客户端连接和断开的BroadcastReceiver
为onReceive()
在其生命周期的唯一方法?
你想在广播接收器中进行位置更新吗?请详细说明你的问题。 –
嗨维尼我问题是当你有来自某人Broascast接收器类将打电话的来电。请检查onReceive()方法何时调用检查Internet连接是否可用。谢谢。 – Jeba