简体   繁体   English

将Genymotion中的Android应用与VirtualBox VM中的Elgg连接

[英]Connecting Android app in genymotion with Elgg in VirtualBox VM

I have the following setup. 我有以下设置。 I have Android Studio configured to run with Genymotion VM. 我已将Android Studio配置为与Genymotion VM一起运行。

Also, I have a Ubuntu 14.04 VM in VirtualBox-4.3 with elgg running as a PHP application on Apache web server. 另外,我在VirtualBox-4.3中有一个Ubuntu 14.04 VM,其中elgg作为Apache Web服务器上的PHP应用程序运行。 The Elgg is an open source social network PHP application. Elgg是一个开源社交网络PHP应用程序。

I have added a test plugin in Elgg. 我在Elgg中添加了一个测试插件 The plugin opens a RESTful API that echoes back a string. 该插件打开一个RESTful API,该API回显字符串。 So I can go to the browser in the Ubuntu VM and type 因此,我可以转到Ubuntu VM中的浏览器并输入

localhost/<some-url>?string=hello+world

and the page returns a json 然后页面返回一个json

{"status":0,"result":"hello world"}

Now I need to write a Android app that can send the same request. 现在,我需要编写一个可以发送相同请求的Android应用。 The Android app needs to be running in the Genymotion VM and needs to talk to the Apache Web Server running in the VirtualBox Ubuntu VM. Android应用程序需要在Genymotion VM中运行,并且需要与VirtualBox Ubuntu VM中运行的Apache Web Server进行通信。 It needs to send a request to the same URL (using IP address probably) and get back the json and display it. 它需要将请求发送到相同的URL(可能使用IP地址),然后返回json并显示它。

I have a hint that it will involve port forwarding kind of thing. 我暗示它将涉及端口转发之类的事情。

Can anyone suggest how exactly should I set this up ? 谁能建议我应该如何设置呢?

The way I made this work was to put the Ubuntu VM in Host-only networking mode in VirtualBox. 我进行这项工作的方法是将Ubuntu VM置于VirtualBox中的仅主机联网模式。 The two VMs can talk to each other. 两个虚拟机可以互相通信。 The Android app in the Genymotion VM can then access the Elgg PHP application running in the Ubuntu VM using the right IP address and port number for Apache. 然后,Genymotion VM中的Android应用程序可以使用适用于Apache的正确IP地址和端口号访问在Ubuntu VM中运行的Elgg PHP应用程序。

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

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