Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load first page on splashscreen using phonegap on android

Hi i'm using phonegap in conjunction with Jquery mobile. I'm trying to immediately fetch the main page, while showing the user a splashscreen.

In PhoneGap for Android i'm using this

super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 2000);

While this loads the splash, it also delays the loading of index.html. It it possible to start fetching it right away? Also, if not with phonegap, has anybody done this using JQM instead of phonegap?

UPDATE: After using it with a slower loading first page (doing a json request) it kinda looks like the splash screens shows for a longer period of time, so this appears to be the default behavior

like image 517
Syg Avatar asked Nov 14 '22 10:11

Syg


1 Answers

As given here, you could kill the splashscreen once you have loaded all the assets and DOM elements have been loaded.

something like this: Java:

super.setIntegerProperty("splashscreen",R.drawable.splashscreen);
super.loadUrl("file:///android_asset/www/index.html", 2000);

on your HTML, javascript section:

function onDeviceReady() 
            {
                cordova.exec(null, null, "SplashScreen", "hide", []);
                window.MacAddress = new MacAddress();
                window.MacAddress.getMacAddress(function(result){
                    database._mac_address = result.mac;
                }, function(){
                    database._mac_address = '01:02:03:04:05:06';
                });  
            }
like image 90
Keshav Avatar answered Nov 16 '22 03:11

Keshav