Testing an Application on a Mobile Device (Magic xpa 4.x)
While developing an application for mobile devices you want to run the programs on the same platform to make sure everything is working properly. In order to do this you need to use your local machine as the application server; however, you do not always have a device or your device cannot always communicate with your machine.
Section A: The Main Techniques and How to Set the Environment
There are four techniques that will help you test your application on a mobile device:
-
Use the WiFi capabilities of the device to connect your device to the same network as your local machine. If you only have a wired network you need a router to connect with WiFi.
-
Use emulators to run a virtual device on your machine. The emulators can be downloaded from the OS provider’s websites:
The emulators use the internet connection of your machine.
Note that you do no need to have an internet connection, because you are already connected to the server.
You need an internet connection only if you need an external resource, such as integration with Google Maps.
-
If you have a device and this device supports USB tethering you can connect the device to your machine, enable the USB tethering and then use the IP address that was given to your machine as the server in your execution.properties file.
To make sure that the server has the same IP every time you connect your device and to decide whether the PC will use the internet connection of the device, refer to section B of this document. Note that while using this method the device will use the 3G internet connection.
-
If you develop on a machine that has WiFi capabilities, you can use that WiFi to turn your machine into a wireless hotspot and connect your device to that hotspot with its WiFi capabilities. To turn your machine into a hotspot, you can use these command lines:
- netsh wlan set hostednetwork mode=allow ssid=%SID% key=%PASS% – defines the wireless network
- netsh wlan start hostednetwork – starts the network
- netsh wlan stop hostednetwork – stops the network
- netsh wlan show hostednetwork – shows the status
The PASS in the first command should contain at least eight characters and should be executed only once. After the first command you can start and stop with the 2nd and 3rd commands.
To keep the IP every time you start the hotspot and in order to decide if your device will use the internet connection of your PC, refer to section B.
Note that you do not need to have an internet connection because you are already connected to the server. You need internet connection only if you need an external resource, such as integration with Google Maps.
There are third party tools, such as Connectify and Virtual routers, that can turn the PC into a WiFi hotspot if you do not want to set everything by yourself.
Section B: Setting a Static IP to the New Network Adapter
To make sure that the server has the same IP every time you connect your device, you should set a static IP address.
-
Go to the Network and Sharing Center.
-
Click on the required connection and click the Properties button.
-
Click the Internet Protocol Version 4 (TCP/IPv4) option. The Internet Protocol Version 4 (TCP/IPv4) Properties dialog box opens.
-
To prevent your machine from using the 3G of the device (technique number 3), leave the Default gateway empty.
-
If you want to share the internet connection of your PC (technique 4), then after you define your hotspot (with the command lines or with the GUI), go to the properties of your main connection (mostly your Ethernet connection).
-
In the Local Area Connection Properties dialog box’s Sharing tab, check the Allow other network users to connect through this computer’s internet connection box.
-
Select the wireless adapter that was created for your new hotspot.