Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is what I had to do in order to get the device to pick up a local service instance on my windows PC running on localhost.</p> <ul> <li>Turn on WiFi on my device and connect to the wireless network.<br /></li> <li>Run ipconfig in the command prompt.<br /></li> <li>Use the IPv4 Address for my Ethernet Adapter Local Area Connection (since I'm connected via ethernet)</li> <li>Change the base url in the android application to use <a href="http://192.168.1.100%3aport/yaddayadda" rel="nofollow">that address</a></li> </ul> <p>Then my android application was able to connect to the local service instance via that IP address rather than 10.0.2.2, which works when you're running the application on the emulator. If one was so inclined, you could extract those urls and check whether the application was running on the emulator or the device, and then set the ip address appropriately in code. Hope this helps.</p> <p>Edit in regard to above url extraction - I created an ApplicationName.java file and declared this variable:</p> <pre><code>public static String ANDROID_DEVICE_ID = ""; </code></pre> <p>Then set that variable in my initial activity:</p> <pre><code>ApplicationName.ANDROID_DEVICE_ID = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); </code></pre> <p>Then I copy pasted that device Id, and in my api class that makes the web service calls I have the following code:</p> <pre><code>private String getCategoriesUrl() { // TODO: Remove before production if (AgoraApplication.ANDROID_DEVICE_ID.equals("deviceIdString")) { _categoriesUrl = _deviceIp + _categoriesUrlSuffix; } else { _categoriesUrl = _emulatorIp + _categoriesUrlSuffix; } return _categoriesUrl; } </code></pre> <p>So when I'm debugging on either device or emulator my application automatically uses the appropriate IP address for service calls.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload