/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitSensors.java
ZANavi

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitSensors.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File size: 2019 byte(s)
import files
1 /*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.zoffcc.applications.zanavi;
17
18 import android.content.Context;
19 import android.hardware.Sensor;
20 import android.hardware.SensorEvent;
21 import android.hardware.SensorEventListener;
22 import android.hardware.SensorManager;
23
24 public class NavitSensors implements SensorEventListener
25 {
26 private SensorManager mSensorManager = null;
27 private int callbackid;
28
29 public native void SensorCallback(int id, int sensor, float x, float y, float z);
30
31 NavitSensors(Context context, int cbid)
32 {
33 //Log.e("NavitSensor", "**NavitSensors started**");
34 // disable to save battery. sensors i think are not used for now, anyway
35 // mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
36 // mSensorManager.registerListener((SensorEventListener) this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
37 // mSensorManager.registerListener((SensorEventListener) this, mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL);
38 callbackid = cbid;
39 }
40
41 public void onAccuracyChanged(Sensor sensor, int accuracy)
42 {
43 }
44
45 public void onSensorChanged(SensorEvent sev)
46 {
47 //Log.e("NavitSensor", "Type:" + sev.sensor.getType() + " X:" + sev.values[0] + " Y:" + sev.values[1] + " Z:" + sev.values[2]);
48 SensorCallback(callbackid, sev.sensor.getType(), sev.values[0], sev.values[1], sev.values[2]);
49 }
50 }

   
Visit the ZANavi Wiki