[英]Get actual location rather than mocked location
Android has a option in developer options to mock location. Android在开发人员选项中提供了一个模拟位置的选项。 If my understanding is correct, if you set this location, the applications will start getting this location rather then the actual location?
如果我的理解是正确的,那么如果您设置此位置,应用程序将开始获取此位置,而不是实际位置?
If that is the case, how can we get the actual location regardless of what is set in this option? 如果是这样,无论此选项中设置了什么,我们如何获取实际位置?
If this is not the case, when is the mock location actually used (only in emulators?)? 如果不是这种情况,什么时候才实际使用模拟位置(仅在模拟器中使用?)?
As per my knowledge, we cant't get actual location if we are using MOKE location, 据我所知,如果使用的是MOKE位置,我们将无法获得实际位置,
Use of Moke location 使用Moke位置
Suppose you are developing a application in Australia region, and you want to test your application in USA environment (Location only) without going there, In that case we are using Moke location. 假设您正在澳大利亚地区开发应用程序,并且想在美国环境中(仅位置)测试应用程序,而无需前往那里,在这种情况下,我们将使用Moke位置。
I think location coming from android frameworks library , and these apis written is such a way, if you was set Moke location, then api will give priority to moke location only. 我认为位置来自android frameworks库,而编写的这些api就是这样一种方式,如果您设置了Moke位置,则api将仅优先于moke位置。 So if you want to use actual location you need to stop moke loaction.
因此,如果您想使用实际位置,则需要停止模拟运动。
You can write your own api which will directly talk to gps, then might be you will do it, But its major project itself 您可以编写自己的api,该API将直接与gps通讯,然后可能您会这样做,但是它的主要项目本身
EDIT 编辑
You can check MockSetting option is on or off 您可以检查“模拟设置”选项是打开还是关闭
/**
*returns true if mock location enabled, false if not enabled.
**/
public static boolean isMockLocationStatus(Context context) {
if (Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ALLOW_MOCK_LOCATION).equals("0"))
return false;
else
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.