简体   繁体   English

如何将GPS发送到Android模拟器

[英]How to send GPS to a android emulator

How can I send simulated GPS positions to the emulator? 如何将模拟的GPS位置发送到模拟器? (This is not a repeated question because I have tried other solutions, don't work) (这不是重复的问题,因为我尝试了其他解决方案,所以行不通)

1) Opened the Tools->Android->Android Device Monitor The Emulator Control Tab with the Location Controls are un Editable. 1)打开“工具”->“ Android”->“ Android设备监视器”。带有“位置控制”的“模拟器控制”选项卡不可编辑。

2) The emulator also has the "..." option which opens a control panel with Location. 2)仿真器还具有“ ...”选项,可使用“位置”打开控制面板。 There I can see GPS data point and Send, but even if I do nothing changes to my program 在那里,我可以看到GPS数据指向和发送,但是即使我什么都不做,程序也不会改变

public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        if (mMap != null) {
            mMap.setMyLocationEnabled(true);
            mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        }

3) If I have to use terminal, how do I know which port the emulator is attached. 3)如果必须使用终端,我怎么知道仿真器连接到哪个端口。

I have used genymotion and it works well, except can not install google maps there yet. 我已经使用了genymotion,它运作良好,但无法在此处安装google地图。

to answer your third part of your question first: the port your emulator is attached is written on top of your emulator window 首先回答问题的第三部分:仿真器所连接的端口写在仿真器窗口的顶部

There is written the name and afterwards the ports (default would be :5554) 上面写着名字,然后是端口(默认为:5554)

emulator_name_port

To answer point one and two of your question: 要回答问题的第一和第二点:

to tell emulator fake gps data via command line you need to connect via telnet: 通过命令行告诉仿真器伪造的gps数据,您需要通过telnet连接:

telnet localhost <your emulator port>

afterwarts it asks you for your auth token. 事后要求您提供身份验证令牌。 the console will show you path where it is located. 控制台将显示路径。 You need to enter the token via 您需要通过输入令牌

token_location

auth <your auth token>

now you have a connection to your emulator and tell him whatever you want. 现在您已经与仿真器建立了连接,并告诉他您想要的任何内容。

You can find a complete documentation of all commands at https://developer.android.com/studio/run/emulator-commandline.html 您可以在https://developer.android.com/studio/run/emulator-commandline.html上找到所有命令的完整文档。

... or you type help into your console ;) ...或者您在控制台中输入help ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM