开发者

phonegap, connection to server unsuccessful

I'm 开发者_StackOverflowtrying to write an Android app with phonegap, and I'm writing a static front page with buttons, which was working until I introduced jQuery mobile and jQuery (which are linked as external files). Now, it gives me this error message (after it produces a blank window for 30 seconds or so):

Connection to server was unsuccessful to "www/assets/index.html"

Since the message flashes away, I cannot read anymore. Any help?


What exactly do you mean by "linked as external files"?

The jQuery Mobile and jQuery sources either need to be in the assets/www directory or linked to externally on an accessible cdn site with wireless or mobile data enabled.

There's an example here.

Also, see JQuery Mobile + PhoneGap for Android - Error loading index.html - Within your custom Activity file before calling super.loadUrl add the following line: super.setIntegerProperty("loadUrlTimeoutValue", 60000);


Far better solution is to keep a extremely light file as for initial load and then redirect to original index.html. For example:

<!doctype html>
<html>
  <head>
   <title>tittle</title>
   <script>
       window.location = './index.html';
   </script>
  <body>
  </body>
</html>


This solved my problem

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/home/index.html");
    super.setIntegerProperty("loadUrlTimeoutValue", 10000); 

I have added super.setIntegerProperty("loadUrlTimeoutValue", 10000); to com.mypackage.xxx.java file for 10 second waiting waiting time.


I suspect that the problem is that you have the super.loadUrl() entered incorrectly. loadUrl should have this string file:///android_asset/www/index.html and actually be located in assets/www/.

The missing 's' threw me off personally.

Edit:

Some other things to check:

  • The browser is able to access the internet
  • Permissions to access the internet.
  • Try downloading the jquery, and jqm libraries to the device and storing them with index.html. Because the emulator is slow, it may be interfering with the page's response to downloading the libraries. Storing locally should avoid that.


hi i think u load multiple scripts in starting time so u do some thing like this

<!doctype html>

<html>

    <head>

        <title>tittle</title>

        <script>

            window.location='./main.html';

        </script>

    <body>      

    </body>

</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜