5

I have a question regarding this event here, deviceready.

document.addEventListener('deviceready', function() {
    app.init();
}, false);

It appears the event is fired every time the device (I'm working on Android 2.3) is tilted to the side (So that the display changes to wide). I guess this is the intended behavior, but is there any way to prevent it, as my application needs to be initialized only once?

boulaycote
  • 602
  • 1
  • 6
  • 18
  • Would love to answer this in a more correct way but I need to jet, a quick hack answer is `app.init = function(){};` right after the `app.init()` call :P – lsl Oct 11 '11 at 12:10
  • Starred will come back tomorrow! – lsl Oct 11 '11 at 12:11
  • Good guess, but it looks like the DOM gets reloaded every time. So changing javascript won't do it I'm afraid. – boulaycote Oct 11 '11 at 13:15
  • 1
    I don't think there is going to be a way around this, I'm pretty sure thats the intended design (think about market app it does the same thing). You probably just want to disable landscape rotation for the app? `` – lsl Oct 11 '11 at 20:53
  • Oh sorry if I sounded harsh, english is not my primary language. That second solution is a good idea, i'll look into that! – boulaycote Oct 11 '11 at 21:28
  • LoL. Not you, I meant the dom reloading. Sounds mental. Probably logical though. – lsl Oct 11 '11 at 22:04

1 Answers1

0

Here is a link to the solution

How do I disable orientation change on Android?

By adding

android:configChanges="keyboardHidden|orientation"

to your activity in the AndroidManifest.xml file, it tells the app that you will handle the configChanges yourself.

Community
  • 1
  • 1
boulaycote
  • 602
  • 1
  • 6
  • 18