Android Quick Settings notifications?

╄→гoц情女王★ 提交于 2020-05-18 14:37:01

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/29477490/android-quick-settings-notifications

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!