谷歌地图和被动提供商 [英] Google map and passive provider

查看:202
本文介绍了谷歌地图和被动提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与被动的供应商合作,与此code。

I'm working with passive provider, with this code.

Intent intent = new Intent(PASSIVE_ACTION);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
mLocationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, pi);

和我定义在AndroidManifest.xml广播接收机

and I define broadcast receiver in AndroidManifest.xml

<receiver
    android:name="passiveLocationReceiver"
    android:enabled="true" >
        <intent-filter>
            <action android:name="com.passive_location_update" />
        </intent-filter>
</receiver>

passiveLocationReceiver是

passiveLocationReceiver is

public class passiveLocationReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (!PASSIVE_ACTION.equals(action))
            return;

        Log.d("chitacan","Passive Provider Event!!!");
        }
    }

这code正常工作时,其他地理位置的应用程序(脸谱,四角..等)
但随着谷歌地图应用程序,它没有。( d.android .COM 解释说,PASSIVE_PROVIDER,可以在其他应用程序请求位置更新。)

This code works fine when other geo location applications(facebook, foursquare.. etc) But with "Google Map" application, It doesn't.(d.android.com explains "PASSIVE_PROVIDER" that can be updated when other application requests locations.)

虽然我可以看到我的位置。谷歌地图应用程序,但我无法从被动提供的任何事件。(我看不出passiveLocationReceiver的日志信息。)

Even though I can see my location with "Google Map" application, but I can't get any event from passive provider.(I can't see passiveLocationReceiver's log message.)

好吧,我试图倾倒的LocationManager在命令行状态,

Well, I tried to dump LocationManager's state in command line,

$adb shell dumpsys location

不过的LocationManager的状态没有任何改变。好像谷歌地图应用程序
不使用的LocationManager

However LocationManager's state didn't change anything. Seems like "Google Map" Application doesn't use LocationManager.

有没有什么办法让被动的事件,当谷歌地图应用程序更新我的位置?
还是我做错了什么?

Is there any way to get passive event when "Google Map" application updates my location?? or Am I doing something wrong??

推荐答案

requestLocationUpdates只会收到变更或更新,以位置值。谷歌地图将播出由GPS定位提供商所提供的位置值的变化。

requestLocationUpdates will only receive changes or "updates" to location values. Google Maps will broadcast changes in location values that are provided by the GPS Location provider.

如果从模拟器测试,尝试输入你的模拟位置的新值。否则,当走动测试。

If testing from an Emulator, try entering a new value for your mock location. Otherwise, test while walking around.

不过,我已经注意到了太多的Wi-Fi(网络)位置的变化不是广播从谷歌地图喜欢他们与其他类似的应用程序。

However, I have noticed too that Wi-Fi (network) locations changes are not broadcast from Google Maps like they are from other similar apps.

在您的个案也许是GPS未启用,或者还没有从当前状态改变位置,因此,你没有在位置接收到任何更新到这个监听器。 (我发现这个话题,因为我想知道为什么谷歌地图并没有广播的Wi-Fi位置的变化,如果有人数字了这一点)

In your case- perhaps the GPS is not enabled, or it hasn't changed location from its current state and therefore you are not receiving any "updates" in location to this listener. (I found this topic because I was wondering why Google Maps was not broadcasting Wi-Fi location changes if anyone figures that out)

这篇关于谷歌地图和被动提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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