我应该向Google地图付款以在Android应用中发出GPS坐标请求吗?

时间:2018-09-26 12:41:38

标签: android google-maps google-api gps google-geolocation

我的目标是每5秒获得一次纬度和经度。

我已经通过在清单中添加ACCESS_FINE_LOCATION权限并通过创建LocationManager实例,然后实现LocationListener来获取坐标的方式将其存档。

现在,没有明显的原因,我停止从onLocationChanged函数获取结果,并且出现了CancellationException错误:

E/RequestManagerImpl: Producing location failed
                                                  java.util.concurrent.ExecutionException: java.util.concurrent.CancellationException: Task was cancelled.
                                                      at dagger.producers.Produced$Failed.get(SourceFile:3)
                                                      at com.google.android.apps.gsa.staticplugins.cy.j.ac.a(SourceFile:98)
                                                      at com.google.android.apps.gsa.staticplugins.cy.j.am.aH(SourceFile:11)
                                                      at dagger.producers.internal.AbstractProducesMethodProducer.aD(SourceFile:11)
                                                      at com.google.common.util.concurrent.r.av(SourceFile:5)
                                                      at com.google.common.util.concurrent.q.run(SourceFile:17)
                                                      at com.google.common.util.concurrent.bx.run(SourceFile:3)
                                                      at com.google.android.apps.gsa.taskgraph.d.a.r.run(SourceFile:7)
                                                      at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source)
                                                      at com.google.android.apps.gsa.shared.util.concurrent.b.bk.run(SourceFile:3)
                                                      at com.google.android.apps.gsa.shared.util.concurrent.b.bk.run(SourceFile:3)
                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                      at java.lang.Thread.run(Thread.java:818)
                                                      at com.google.android.apps.gsa.shared.util.concurrent.b.m.run(SourceFile:6)
                                                   Caused by: java.util.concurrent.CancellationException: Task was cancelled.
                                                      at com.google.common.util.concurrent.d.fi(SourceFile:78)
                                                      at com.google.common.util.concurrent.d.get(SourceFile:60)
                                                      at com.google.common.util.concurrent.cv.n(SourceFile:1)
                                                      at com.google.common.util.concurrent.bc.p(SourceFile:33)
                                                      at com.google.common.util.concurrent.a.run(SourceFile:14)
                                                      at com.google.common.util.concurrent.ar.execute(SourceFile:3)
                                                      at com.google.common.util.concurrent.d.a(SourceFile:216)
                                                      at com.google.common.util.concurrent.d.a(SourceFile:184)
                                                      at com.google.common.util.concurrent.d.M(SourceFile:130)
                                                      at com.google.common.util.concurrent.q.run(SourceFile:15)
                                                      at com.google.common.util.concurrent.ar.execute(SourceFile:3)
                                                      at com.google.common.util.concurrent.d.a(SourceFile:216)
                                                      at com.google.common.util.concurrent.d.a(SourceFile:184)
                                                      at com.google.common.util.concurrent.d.cancel(SourceFile:95)
                                                      at com.google.android.apps.gsa.taskgraph.d.a.w.run(SourceFile:3)
                                                      at com.google.android.apps.gsa.taskgraph.d.a.m.run(Unknown Source)
                                                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                                                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                      at com.google.android.apps.gsa.taskgraph.d.a.e.run(SourceFile:17)
                                                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                                                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                      at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source)
                                                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                                                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
                                                      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                      at java.lang.Thread.run(Thread.java:818) 
                                                      at com.google.android.apps.gsa.shared.util.concurrent.b.m.run(SourceFile:6) 

在互联网上搜索时,我发现有人说这与2018年7月16日生效的新版Google Maps定价变化有关。

我没有使用任何路线或地图服务。我只需要每5秒获取一次纬度和经度即可。我是否应该创建一个API密钥并将其放在代码中的某个位置以使代码再次正常工作?

谢谢!

0 个答案:

没有答案