Skip to content Skip to sidebar Skip to footer

Phonegap/cordova Blank Screen On Pause/resume

I have a simple html/javascript app that starts and works up fine on an Android device. However, when the app is put in background by using the 'home button' and then brought back

Solution 1:

I was having the same problem and I want to share a hack that worked for me.

My app is based on ionic/angular/cordova and the android version was giving me a white screen around 50% the times on pause/resume.

When it happened, tapping anywhere on the screen or hitting the back button would make the screen to render again just fine.

I added a div tied to a scope variable named random, like this:

<bodyng-app="starter"id="body"><div>{{ random }}</div><ion-nav-view></ion-nav-view></body>

Then I added a listener inside my app.js to capture the resume event fired by cordova, to then change the random variable and call $apply(), like this:

document.addEventListener("resume", function() {
  angular.element(document.querySelector('#body')).scope().random = Math.random();
  angular.element(document.querySelector('#body')).scope().$apply();
})

Since the ion-nav-view takes over the whole screen that div never shows up, but angular doesn't know that and refreshes the page, causing the whole thing to work.

(I tried to tie the variable to an invisible element but then angular doesn't refresh the page)

I hope this helps someone!

Solution 2:

There seem to be issues around rendering the pages thru PhoneGap and 'Dialog'ing thru Client side FB authentication flow using the JS SDK. If I disable the client side authentication, then the rendering and display of the page works very well, when the app is brought to foreground from background (pause/resume/etc).

I am assuming that the page will need to sense that it is being displayed over a mobile device and use the IOS or Androi SDK for client side authentication.. (if/when I get around to testing that, I update the answer - if there is anybody who has any more light to shed, please feel free to embellish).

Solution 3:

If you still say "I am happy for the app to exit every time the home button is entered and then do a full restart when the app is clicked on the mobile." then go for it.

@OverrideprotectedvoidonStop(){
super.onStop();
}

Try this from where you create activity or from the class which "extends DroidGap".

Post a Comment for "Phonegap/cordova Blank Screen On Pause/resume"