Android phone not working

I am writing my first application in Phonegap and I tested it on an Android device. I believe that I have given the appropriate permission:

<uses-permission android:name="android.permission.INTERNET" /> 

But the map is not displayed. I am trying to get latitude and longitude from a web service and use this to put a flag on a google map. I believe that the problem is related to Internet access, as if I ran it through Visual Studio as a website, the service returns the coordinates and a map is displayed. However, when the application is compiled and this website is launched in the application’s web application, the coordinates are not returned and the map is not displayed.

I also added a table to display the returned coordinates, again they are displayed in the browser, but in the running application they are empty. Does anyone know why web browsing will not be able to connect to the Internet and return the required data? I deleted the actual web service address, but I know this is normal as it works in the browser.

HTML page:

 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=true"></script> <link rel="stylesheet" type="text/css" href="css/index.css" /> </head> <body> <div class="app2"> <div id="map" style="width: 200px; height: 150px"></div> <script type="text/javascript"> var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://www.xxxxxxxx.com/mobile/iphone/xml/postal.asp?postal=33173", false); xmlhttp.send(); xmlDoc = xmlhttp.responseXML; var myOptions = { zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP, }; var map = new google.maps.Map(document.getElementById("map"), myOptions); var lat = x[i].getElementsByTagName("latitude")[0].childNodes[0].nodeValue; var long = x[i].getElementsByTagName("longitude")[0].childNodes[0].nodeValue; var pos = new google.maps.LatLng(lat, long); var infowindow = new google.maps.InfoWindow({ map: map, position: pos, content: "Postcode 33173(Lat:" + lat + ", Long:" + long + ")" }); map.setCenter(pos); </script> <script> document.write("<table border='1'>"); document.write("<tr><td>Postcode</td><td>latitude</td><td>longitude</td></tr>"); var x = xmlDoc.getElementsByTagName("position"); for (i = 0; i < x.length; i++) { document.write("<tr><td>33173</td><td>"); document.write(x[i].getElementsByTagName("latitude")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("longitude")[0].childNodes[0].nodeValue); document.write("</td></tr>"); } document.write("</table>"); </script> </div> </body> </html> 

manifest:

 <?xml version='1.0' encoding='utf-8'?> <manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="dig.phonegap.loa_app" xmlns:android="http://schemas.android.com/apk/res/android"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="18" /> <application android:allowBackup="false" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="HelloWorld" android:theme="@android:style/Theme.Black.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 
+7
android web-services google-maps cordova webview
source share
3 answers

Try this on config.xml :

Plaform -> android -> res -> xml -> config.xml

Plaform -> ios -> config.xml

Plaform -> wp7 -> config.xml

Plaform -> wp8 -> config.xml

 <access origin="*" /> 
+8
source share

I had the same problem and I had to add the following to config.xml .

 <access origin="*" /> <plugin name="cordova-plugin-whitelist" version="1" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" /> <platform name="android"> <allow-intent href="market:*" /> </platform> <platform name="ios"> <allow-intent href="itms:*" /> <allow-intent href="itms-apps:*" /> </platform> 
+6
source share

Make sure you have the following parameter in res / xml / config.xml:

  <access origin="*" /> 
+3
source share

All Articles