android.location.Location制定者未按预期 [英] android.location.Location setters not working as expected

查看:196
本文介绍了android.location.Location制定者未按预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一些纬度和经度值Location对象,而无需通过位置提供下去。我做到以下几点:

I need to create a Location object from some latitude and longitude values, without going through a location provider. I do the following:

Location l = new Location("");
l.setLatitude(32);
l.setLongitude(43);

的值,但是,设置不正确,因为两个 getLatitude() getLongitude()返回0

能否请你告诉我问题出在哪里?这不是创建一个自定义位置的正确方法是什么?

Can you please tell me where is the problem? Isn't this the correct way to create a "custom" Location?

推荐答案

我想通了也说不定。当使用Android API的单元测试,你需要使用仪器框架。我使用JUnit孤单,从而出现故障。
我用Roboelectric,工具类的,模拟的Andr​​oid平台允许您运行使用Android的API不用每次都带来了一个设备模拟器单元测试解决。

I figured it out eventually. When unit testing using the Android APIs, you need to use the instrumentation framework. I was using JUnit alone, thus the malfunctioning. I resolved by using Roboelectric, a tool that sort of emulates the Android platform allowing you to run unit tests that use Android APIs without bringing up a device emulator every time.

这篇关于android.location.Location制定者未按预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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