phonegap, connection to server unsuccessful

前端 未结 5 1887
花落未央
花落未央 2020-12-15 08:35

I\'m trying 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 ar

相关标签:
5条回答
  • 2020-12-15 09:02

    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>
    
    0 讨论(0)
  • 2020-12-15 09:04

    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.
    0 讨论(0)
  • 2020-12-15 09:05

    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);

    0 讨论(0)
  • 2020-12-15 09:06

    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.

    0 讨论(0)
  • 2020-12-15 09:21

    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 讨论(0)
提交回复
热议问题