5

I am working on application which will handle a few device-specific things, but then redirect the user to an online webpage. This is all working well in iOS build and I am trying to get it to work in Android.

Currently in Android, the app loads, but does nothing with if I have a window.location.href = ... call in the window.onload. One of the settings that was necessary for iOS was OpenAllWhitelistURLsInWebView. Is there a similar setting for Android? How do you set it? Any other recommendations?

Rob
  • 7,377
  • 7
  • 36
  • 38
  • U made it working on iphone right?... How did u contact the server in Iphone? – coderslay Apr 03 '12 at 17:18
  • The page itself essentially does a `window.location.href = 'url'`. In xcode I updated the whitelisted hosts and changed the `OpenAllWhitelistURLsInWebView` setting to true. The one other thing I'm realizing I changed is I currently return `YES` in `webView:shouldStartLoadWithRequest:navigationType` (I am going to change it shortly to only return `YES` for the domain in question). Is there something similiar on the android side? – Rob Apr 03 '12 at 17:25
  • Please read this article. http://stackoverflow.com/questions/8596772/how-can-i-load-a-webpage-inside-the-phonegap-webview – ANNotunzdY Nov 27 '12 at 19:23
  • Please read following article: http://stackoverflow.com/questions/8596772/how-can-i-load-a-webpage-inside-the-phonegap-webview – ANNotunzdY Nov 27 '12 at 19:24
  • Please read following article: http://stackoverflow.com/questions/8596772/how-can-i-load-a-webpage-inside-the-phonegap-webview – ANNotunzdY Nov 27 '12 at 19:25
  • Please read following article: http://stackoverflow.com/questions/8596772/how-can-i-load-a-webpage-inside-the-phonegap-webview – ANNotunzdY Nov 27 '12 at 19:26

2 Answers2

0
<access origin="www.google.com"/>

to the res/xml/config.xml file.

ANNotunzdY
  • 379
  • 1
  • 3
  • 14
0

According to me... The Concept of using Phonegap will be creating a universal code which will work for every mobile platform...

if you need to make a server request then do it like this

<!DOCTYPE HTML>
<html>
<head>
<title>Index Page</title>

<!-- Adding viewport -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Adding Phonegap scripts -->
<script type="text/javascript" charset="utf-8"
src="cordova/cordova-1.5.0.js"></script>

<!-- Adding jQuery mobile and jQuery scripts & CSS -->
<script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script>
<link rel="stylesheet"
href="jquerymobile/jquery.mobile-1.1.0-rc.1.min.css" />
<script type="text/javascript"
src="jquerymobile/jquery.mobile-1.1.0-rc.1.min.js"></script>

<script type="text/javascript">

function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {

$.ajax({
    type : 'GET',
    cache : false,
    url : "http://192.168.1.198:9051/something.xml"
            + "?time=" + Date.now(),
    data : {
        key : "value"
    },
    dataType : "xml",
    success : function(xml) {
        console.log("Success Page1");
    },
    error : function(xhr) {

    }
});
}
</script>

In case of iOS... The above code will not contact the Server because apple doesnt allow us to contact to external servers until we specify it like through ExternalHosts in cordova.plist

But in case of Android. You don not have to do anything.It will contact the server with out any external configurations..:)

coderslay
  • 13,960
  • 31
  • 73
  • 121
  • I think in a round about way this "answers" my questions. I am able to load an external URL using the super.loadUrl in the Java code. Unfortunately not the server I'm after (that timesout), but that's probably a whole other ball of wax... – Rob Apr 03 '12 at 19:17