English 中文(简体)
如何监听定位提供者被启用/ 禁用?
原标题:How to listen for location providers becoming enabled / disabled?

当定位提供商被启用或禁用时,如果它不实际查寻设备的位置(因为这样做可能会使用大量电力),能否得到通知?

问题回答

In android 里有位置倾听器界面, 它为 ProviderEnabled (String 提供商) 提供了一个抽象的方法。 所以您已经创建了自己的倾听器, 并实施了 ProviderEnabled (String 提供商) 方法 。 您的倾听器必须在位置管理器中注册 。

如果采取与上文所述相同的做法,则在启动所在地提供商时,在ProviderEnabled(供应商)上将自动调用。

< a href=" "http:// developmenter.android.com/ reference/android/location/LocationManager.html#is ProviderEnabled%28java.lang.String%29" rel="nofollow">Locationmanager.is provviderEnabled () 似乎并不需要实际查找这个位置。它不会太有效率,因为您需要调查它,但比获取实际位置要好。

实际上,读更多关于这个主题的文献,似乎你可以使用 < a href=" http:// developmenter.android.com/ reference/android/location/LocationManager.html#requestLocationUpdates%28lod,%20float,%20android.orgate.cret.Criteria,%20android.app.PendingIntent%29" rel="nofollow">requestLocationUpateddates () <() to do this. 它将在服务商被启用或禁用时发送一个有 KEY_PROVIDE_ENCLAD 的包件。 您可以设定通知的最小时间和距离至极高值。 这样您可以一次获得定位通知,, 并且大多只是启用/残疾通知 。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...