无需插入 SIM 卡即可获取纬度和经度,并从应用程序启动/停止 Gps [英] Get Latitude and Longitude without inserting Sim Card and Start/Stop Gps from Application

查看:23
本文介绍了无需插入 SIM 卡即可获取纬度和经度,并从应用程序启动/停止 Gps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 Gps 纬度和经度,但我有一个查询,每当我尝试获取 Lat &长时间没有 sim 卡,它没有提供任何信息,只要我插入我的 sim 卡,它就会以所需的方式为我提供所有信息.

I am trying to fetch Gps latitude and longitude, but i am having a query that whenever i try to fetch Lat & Long without sim card, it is not providing any info where as soon i insert my sim card, it provides me all information in desired manner.

LocationManager mlocManager = 
    (LocationManager) getSystemService(Context.LOCATION_SERVICE);

LocationListener mlocListener = new MyLocationListener();

mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                                   0, 0, mlocListener);

你可以看到虽然我正在使用 GPS_PROVIDER,但它并没有给我 Lat &长期没有网络运营商的帮助,有人可以给我打电话吗?

you can see though i m using GPS_PROVIDER, it is not giving me Lat & Long without Network Operator help, can anybody tel me?

另一件事是如何从应用程序启动和停止 GPS 意味着我想在特定时间后启动 gps,而不是一旦我得到定位,我可以将其关闭.

Another thing is How to start and stop GPS from an application means i wanna start gps after particular time and than as soon i get beslocation, i can turn it off.

推荐答案

您无需访问任何网络即可在 Android 上获取 GPS 位置.但是互联网连接可以将定位时间从大约 5 分钟缩短到 5 秒(大约)!这种改进是由 辅助 GPS (A-GPS) 带来的,而不是独立 GPS.

You don't need to have access to any network to get a GPS location on Android. But an internet connection speeds-up the location fix from about 5 minutes to 5 seconds (approximately)! This improvement is brought by Assisted-GPS (A-GPS), as opposed to standalone-GPS.

GPS 手机(包括 Android 设备)检查网络连接是否可用.如果是这样,他们会从 A-GPS 服务器下载辅助数据,并使用它来计算 GPS 芯片组的定位.如果没有,GPS 芯片组必须从 GPS 卫星下载数据,这需要很长时间(速率为每秒 50 !).如果不久前计算了 GPS 位置,该过程也可以加快.

GPS phones (including Android devices) check if a network connection is available. If so, they download assistance data from and A-GPS server and use it to compute the location fix with the GPS chipset. If not, the GPS chipset has to download the data from a GPS satellite, which takes a long time (rate is 50 bits per second!). The process can also be sped up if a GPS location has been computed not too long ago.

首先:

  • 检查您是否已将 ACCESS_FINE_LOCATION 添加到清单的权限中
  • 检查手机设置中是否启用了 GPS 卫星
  • 确保您不在室内(20,000 公里以上的卫星发出的信号不喜欢屋顶和墙壁)

然后启动您的应用并等待,在第一个修复可用之前可能需要几分钟.

Then start your app and wait, there can be a few minutes before the first fix is available.

至于从您的应用启动 GPS,这似乎是可能的(请参阅如何在 Android 上以编程方式启用或禁用 GPS?),但我不知道怎么做!至少您可以下载 Tasker 并对其进行编程以启动/停止 GPS.

As for starting the GPS from your app, it seems possible (see How can I enable or disable the GPS programmatically on Android?), but I don't know how! At least you can download Tasker and program it to start/stop the GPS.

这篇关于无需插入 SIM 卡即可获取纬度和经度,并从应用程序启动/停止 Gps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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