I am developing an app in android in which i am making use of json parsing to get data from php file and also sending data to php file from android. This time I am running my app on emulator so I am passing ip address of emulator i.e. 10.0.2.2. Now I want to run that app on android device,so what ip address is needed to passed instead of emulator's address?
Related
I'm trying to get JSON data from a PHP file (Apache/XAMPP) in localhost to Android using only a USB cable. The Android device is offline. Is it possible? Someone suggested using okhttp3 but I can't figure out how to.
If not already tried, Try running the app from emulator first but with the IPv4 address from ipconfig(command promt).use the ipv4 address instead of "Localhost:8080" use "Localhost:" in your code.
To creata apk file for php mobile application.
is it necessary to deploy it in the server before creating apk?
Yes, it is possible,
Enter address as http://ip-address/ followed by the path of your PHP file in your code.
For example http://192.168.1.7/test/example.php
You could get your IP address By executing ifconfig in the terminal
To test your app for Android localhost connection with PHP MySQL in Android Mobile Phone, your computer and mobile phone should be connected to the same Wi-Fi router.
Note: Before putting your address into the code, test address in your mobile browser for whether the address is accessible or not.
I am new to web services and planning to design a php webservice for my android app on my local machine which will send some user informations to database and generate some JSON data. But the problem is i am little confused about how to test it.
For example lets say that my webservice will locate on my local machine like below http://localhost:80/webservice/register.php
And my ip address is 192.168.1.X
Than is it possible for my android app to use this web service by using this url http://192.168.1.X:80/webservice/register.php
Normally since webservices are on the internet any program can access them. But i thought that i can test my webservice with my android app since both my pc and android device are on the same subnet.
If someone make things clear and tell me a way for testing a web service locally i appreciated
This is possible to call the web service in the local network also from the android app. But Your device and Your server on which Web Service running must have on the same network and Your firewall or any proxy server must be off on the server.
I'm trying to create android apps which able sending data through wifi connection to my laptop Apache Server and MySQL database. I use the samsung galaxy tab 10.1 as my mobile device. and the protocol i used is HttpGet or HttpPost. And i use XAMPP( with Apache& SQL) to do the server and process the php. But, due to android cannot detect adhoc network from laptop, i use Virtual Router ( for window 7) to create virtual access point and make the tablet able connect to my laptop. But the problem is:
In my apps (client-android), where the httpget or httppost to which url? localhost in my laptop- 127.0.0.1 or localhost in android 10.0.0.1? or the ip address of the virtual router?
So, if I want access from android to the localhost(laptop-Apache) to call the php to run? which port? which ip address /url that i need to put in android apps(httpget)? and do I need to modify anything in httpconfig for XAMPP?
Find out your Ip address in your laptop using ipconfig . use that address in the phone instead of 127.0.0.1.
as long as you know the I.P Address of the Computer with Apache on it , Since external MySQL access is quite tricky to set up id recommend sending JSON requests to your PHP scripts and getting the return value via Java then what you want to do with the output is upto you.
how can i connect an android app (on my phone) to a php server (EasyPHP) that i am running on my machine (localhost). Are there any tutorials out there that document this.
I need to test the app on an actual phone not an emulator (because the emulator contains bugs for certain activities). Any help would be great!
If you connect on your Android with WiFi, you will be in the same network, then you can access PHP server via your machine's IP address.
Ys you connect to the php script...
Android allows you to sent data in GET and POST method..
I found a useful tutorials about this: Android phpMysql connection