简体   繁体   English

位置服务[访问权限]启用侦听器

[英]Location Service [ Access ] Enable Listener

Is there a some way to register a listener to Location Service, so that when the user enable them in the setting application is notified about it ? 有没有什么方法可以向位置服务注册侦听器,以便在设置应用程序中启用用户时通知用户?

The issue i face is that, i show the user with Alert Dialog to enable location access, usual flow is like, user will click on [Enable] positive response, however elite users many don't go through such a flow and directly enable location access manually via going to settings. 我面临的问题是,我向用户显示“警报对话框”以启用位置访问,通常的流程是,用户将单击[启用]肯定响应,但是精英用户很多都没有经过这种流程而直接启用位置通过转到设置手动访问。 Issue with indirect flow is that, i'm unable to dismiss the dialog. 间接流程的问题在于,我无法关闭该对话框。 A logical solution is the activity listening to location access enable event. 逻辑解决方案是监听位置访问启用事件的活动。 Is there way to register a listener like that ? 有没有办法注册这样的听众?

Another not so neat way to is to dismiss the dialog in the call back 另一个不太整洁的方法是关闭回叫中的对话框

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

            findAddressPositionCamera(location);

 }

I think it is already supported through these functions when you implements LocationListener : 我认为当您实现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.

    }

You just need to use these to keep track of the Location Service status. 您只需要使用这些跟踪Location Service状态即可。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM