Yesterday i have started Phonegap series post and In this second part of our PhoneGap tutorial series, I am going to explain about how to call web service in PhoneGap android application.
Recently I was working on web service for an Android application and I have written ajax code and the web service is running on localhost using the Android emulator but getting below issue.
Read about: Getting Started With PhoneGap
Problem:
If I execute my web service into chrome advanced rest client, It’s working perfect and gives a proper response with data. But when I am going to execute using jQuery ajax method into my android application using PhoneGap, it’s not going into success or error means it’s not giving error or success result.
Solution:
The problem was simple and I have spent more than an hour to find solution so I have checked with java developer and got that my application was not connected to access the internet from the Android Emulator and web service is using remote URL and to access internet,need to write code into AndroidManifest.xml
file.
Must Read: Display Text Format Proper in IPHONE+ANDROID
After all installation of your project or setup of your project,if your webservice not called.Open your AndroidManifest.xml and place below code:
1 2 3 4 | <uses-permission android:name=”android.permission.INTERNET”/> <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE”/> |
That’s it. Run your web service in Android!. I hope that you’ve found this tutorial useful.
Suggested Reading
As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.
Comments (2)