locationclient.getlastlocation()总是返回的模拟器空 [英] locationclient.getlastlocation() always returns null on emulator

查看:497
本文介绍了locationclient.getlastlocation()总是返回的模拟器空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新进的Andr​​oid的世界。我只是指从谷歌这个教程:
http://developer.android.com/training/location/retrieve-current.html

I am new into Android world. I was just referring this tutorial from Google: http://developer.android.com/training/location/retrieve-current.html

程序编译罚款和仿真器启动应用程序,但是当我试图找到mLocationClient.getLastLocation()返回null,总是

Program compiles fine and launches application on emulator, but when I try to find mLocationClient.getLastLocation() it returns null, ALWAYS

我搜索了将近一天ahve已经试过从DDMS,TELNET发送参数,切换谷歌地图,但仍然没有成功。

I searched for almost a day and ahve already tried sending parameter from DDMS, telnet, switching google MAPs but still no success.

请帮助我。

推荐答案

什么最终为我工作是设定的位置(我用Genymotion,所以在右上角的GPS部件),然后开始谷歌地图,并然后运行我的应用程序。

What eventually worked for me was setting a location (I use Genymotion, so the "GPS widget" in the upper right corner), then starting Google Maps, and then running my app.

我的猜测是,我的应用程序实际上并没有设置当前位置(我想我的连接将locationClient自动完成) - 谷歌地图检查并设置位置,所以getLastLocation实际上有一些返回

My guess is that my app wasn't actually setting the current location (which I thought connecting my locationClient would do automatically) - Google Maps checks and sets the location, so getLastLocation actually has something to return.

这篇关于locationclient.getlastlocation()总是返回的模拟器空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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