TAILIEUCHUNG - Android SDK (phần 11)

Using the Compass, Accelerometer, and Orientation Sensors ❘ 467 Sensor accelerometer = (); (sensorEventListener, accelerometer, ); Timer updateTimer = new Timer("gForceUpdate"); (new TimerTask() { public void run() { updateGUI(); } }, 0, 100); } All code snippets in this example are part of the Chapter 14 G-Forceometer project, available for download at . Once you’re finished you’ll want to test this out. Ideally you can do that in an F16 while Maverick performs high-g maneuvers over the Atlantic. That’s been known to end badly, so failing that you can experiment with running or driving in the safety of your neighborhood. Given that keeping constant. | Using the Compass Accelerometer and Orientation Sensors 467 Sensor accelerometer sensorEventListener accelerometer Timer updateTimer new Timer gForceUpdate new TimerTask public void run updateGUI 0 100 All code snippets in this example are part of the Chapter 14 G-Forceometer project available for download at . Once you re finished you ll want to test this out. Ideally you can do that in an F16 while Maverick performs high-g maneuvers over the Atlantic. That s been known to end badly so failing that you can experiment with running or driving in the safety of your neighborhood. Given that keeping constant watch on your handset while driving cycling or flying is also likely to end poorly you might consider some further enhancements before you take it out for a spin. Consider incorporating vibration or media player functionality to shake or beep with an intensity proportional to your current force or simply log changes as they happen for later review. Determining Your Orientation The orientation Sensor is a combination of the magnetic field Sensors which function as an electronic compass and accelerometers which determine the pitch and roll. If you ve done a bit of trigonometry you ve got the skills required to calculate the device orientation based on the accelerometer and magnetic field values along all three axes. If you enjoyed trig as much as I did you ll be happy to learn that Android does these calculations for you. In fact Android provides two alternatives for determining the device orientation. You can query the orientation Sensor directly or derive the orientation using the accelerometers and magnetic field Sensors. The latter option is slower but offers the advantages of increased accuracy and the ability to modify the reference frame when determining your orientation. The following sections .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.