0

是否有某种方法可以向位置服务注册侦听器,以便当用户在设置应用程序中启用它们时会收到通知?

我面临的问题是,我向用户显示警报对话框以启用位置访问,通常的流程就像,用户将单击 [启用] 积极响应,但是许多精英用户不会通过这样的流程并直接启用位置通过进入设置手动访问。间接流的问题是,我无法关闭对话框。一个合乎逻辑的解决方案是监听位置访问启用事件的活动。有没有办法注册这样的听众?

另一个不太巧妙的方法是在回调中关闭对话框

@Override
 public void onLocationChanged(Location location) {
            // check if instantiated 
            if (enableLocationAccessAlert != null) {
                enableLocationAccessAlert.dismissDialog();
            }

            findAddressPositionCamera(location);

 }
4

1 回答 1

1

我认为当您实现时,这些功能已经支持它LocationListener

@Override
    public void onProviderDisabled(String provider) {
        // Called when the provider is disabled by the user. If requestLocationUpdates is called on an already disabled provider, this method is called immediately.

    }

@Override
public void onProviderEnabled(String provider) {
    // Called when the provider is enabled by the user.

}



@Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // Called when the provider status changes. This method is called when a provider is unable to fetch a location or if the provider has recently become available after a period of unavailability.

    }

您只需要使用这些来跟踪Location Service状态。希望这可以帮助。

于 2013-09-10T03:37:10.880 回答