简体   繁体   中英

Screen orientation information generated by Javascript won't display in Android emulator

I'm learning Android development using Pro Android Web Apps (Apress, Auths: Damon Oehlman & Sebastien Blanc). I ran into a snag in the second chapter (not a good sign if I'm having trouble already). I couldn't find any help from the Apress site on the book, so I'm hoping you guys can help me out here.

The chapter has me build an html, css, and js file that are supposed to detect and display the orientation of the device as the user rotates it (rotates the device, that is :) ).

When I run the code in an Android emulator running on my local WAMP server, the page displays ok (I don't think the css is quite right, but that's no big deal), but the data regarding the orientation isn't being displayed at all. I made sure the link to the js file is correct, and I've even downloaded all three files from the Apress site to see if it's something in my code, but those won't work either. The book's code is written for v2.1.

I have posted the code for the three files here . Since I'm working through the book using a local WAMP server, I don't really know how to make it easier for someone to take the files and test them his/herself. Sorry.

I really hope someone can take a look at the code and help me out. I'd really appreciate it, so I can continue on working through the book!

Thanks!

[Edit] I just figured out how to change the orientation in the emulator and the display does rotate, but again, the output that the js is supposed to generate isn't displaying after the bulleted items.

I can't help too much but recommend that you use an actual device for things like this. If you still wish to use the emulator, make sure you choose Android 2.1 for the OS. You can also debug using the equivalent of System.out.println by using Log.d("tagname","line to be displayed"); which will display lines onto DDMS (which if you're using Eclipse can be seen by selecting Window -> View Perspective -> Other -> DDMS which will really help you debug this problem more!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM