尝试获取位置时出现 java.lang.InterruptedException
这是我的代码:
Criteria criteria = new Criteria();
LocationProvider locationProvider = LocationProvider.getInstance(criteria);
Location currentLocation = locationProvider.getLocation(300);
它在第三行抛出异常。我该如何解决这个问题?
Here is my code:
Criteria criteria = new Criteria();
LocationProvider locationProvider = LocationProvider.getInstance(criteria);
Location currentLocation = locationProvider.getLocation(300);
It throws the exception at the third line. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在模拟器中运行您的应用程序吗?如果是,那么您必须更改 IT 策略。
转到“模拟”,选择“设置 IT 策略和策略”。 GPS 位置如下。
我希望这会对您有所帮助..:)
Do you run your application in the simulator? If yes ,then you have to change the IT policy.
Go to Simulate select Set IT Policy & GPS Location as given below.
I hope this will help you.. :)
我想通了。当我处于封闭区域时,GPS 无法接收数据并抛出 InterruptedException。
I figured it out. When I am in a closed area GPS cannot receive data and throws InterruptedException.