Android快速设置通知? [英] Android Quick Settings notifications?

查看:58
本文介绍了Android快速设置通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gms.location.FusedLocationProviderApi中,检查是否启用了位置设置的方法是调用checkLocationSettings.这对轮询非常有用,但是用户可以使用新的快速设置"菜单(从顶部向下滑动)打开/关闭位置,这不一定会触发顶部活动中的onResume(如果打开了位置,则会出现一个对话框,但如果将其关闭,则没有一个.)

In gms.location.FusedLocationProviderApi, the way to check if location settings are enabled is to call checkLocationSettings. That's great for polling, but it's possible for the user to turn location on/off using the new Quick Settings menu (swipe down from top), which does not necessarily trigger onResume in the top activity (if location is turned on, there's a dialog, but if it's turned off, there isn't one).

当快速设置"切换位置时,​​获得通知的正确方法是什么?

What's the right way to get notified when a Quick Setting toggles Location?

推荐答案

答案是...当在快速设置"中对位置进行更改时,将广播android.location.PROVIDERS_CHANGED.

And the answer is... android.location.PROVIDERS_CHANGED is broadcast when a change is made to location in Quick Settings.

    <receiver
        android:name=".LocationProvidersChangedReceiver"
        >
        <intent-filter>
            <action android:name="android.location.PROVIDERS_CHANGED" />
        </intent-filter>
    </receiver>

这篇关于Android快速设置通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆