android-sensors

Not able to fetch correct degree from getOrientation method

时光总嘲笑我的痴心妄想 提交于 2019-12-13 06:59:02
问题 I am trying to get the tilt angel from Android orientation. The values which i am getting from SensorManager.getOrientation(mRotationMatrix, mValuesOrientation) is not degrees.... On putting the phone on a horizontal plane it returns improper values I have tries using few methods found on net without any luck.. So far tried Math.sin(Math.toRadians(mValuesOrientation[0])); Math.toDegrees(mValuesOrientation[0]); and others Code is below public class MainActivity extends Activity { @Override

Accelerometer onSensorChanged not called when screen is off

左心房为你撑大大i 提交于 2019-12-13 02:41:46
问题 I have a background service which is running all the times and collects sensor data. But when the screen dims, it stops collecting the data. I want it to collect even in this case. My device is HTC MyTouch. I have tried prtial wake lock, buy it didn't work. Can anyone please help me fix this problem. Thanks Sowmya 回答1: This is a documented issue: http://code.google.com/p/android/issues/detail?id=3708 Unfortunately no easy fix exists and the workarounds also don't always work. It seems to be

Android device angle on vertical axis while device stays still

ⅰ亾dé卋堺 提交于 2019-12-13 02:41:14
问题 I am developing my first app and for some calculations I need an angle of vertical axis. Basically I am trying to make simple measure tool which would do the calculations on Button click. I have height(H) in which is device and I need angle of device vertical axis. Having these values I'll be able to calculate sin and so on. I tried to use code from this link (finding orientation using getRotationMatrix() and getOrientation()) to get values, but it crashes and also I think it's not the values

compass calibration

半城伤御伤魂 提交于 2019-12-13 02:08:53
问题 So i have been building an AR engine that makes use of the magnetic compass and phone orientation ect.. In the process i built a free stupid AR Compass and in testing i realize that 90% of the time it works GREAT! but occassionally the magnetic compass sensor stops responding.. every doc i have found talks about the user makeing a figure 8 with their device to recalibrate the compass.. and this works SOMETIMES but not always.. is there a way to reset the compass programmatically? testing on

Android - How I receive sensors data in batching mode?

纵然是瞬间 提交于 2019-12-12 20:48:46
问题 KitKat introduced sensor batching, but i cant reading data from sensors in batching mode. My code: public class MainActivity extends AppCompatActivity implements SensorEventListener{ private SensorManager senSensorManager; private Sensor senAccelerometer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); senSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); senAccelerometer =

Resetting Android step counter

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 19:17:20
问题 I need to reset the android step counter on button click. I know while the sensor is activated, the value will keep increasing without resetting to zero until the system is rebooted. I have tried this but it only displays 0; SharedPreferences prefs = getActivity().getSharedPreferences(MY_PREFS, MODE_PRIVATE); stepsAtReset = prefs.getInt("stepsAtReset", 0); btnStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { isPaused = false; isStopped = false;

Android Sensor Shake in the background

风流意气都作罢 提交于 2019-12-12 10:18:37
问题 I'm trying to follow a tutorial about sensor. It works fine with an activity. However, I want this to work in the background when the phone is locked. What's the best way to do that? Here's the link to the tutorial http://jasonmcreynolds.com/?p=388 ShakeDetector class public class ShakeDetector implements SensorEventListener { /* * The gForce that is necessary to register as shake. * Must be greater than 1G (one earth gravity unit). * You can install "G-Force", by Blake La Pierre * from the

Android process is bad error on killing the app

烈酒焚心 提交于 2019-12-12 08:56:59
问题 Here is the exact error 02-08 12:36:43.490 3479-4980/? W/ActivityManager: Scheduling restart of crashed service com.wfl/.StepTrackerShakeDetectorService in 1000ms 02-08 12:36:44.494 3479-3513/? W/ActivityManager: Unable to launch app com.wfl/10139 for service Intent { cmp=com.wfl/.StepTrackerShakeDetectorService }: process is bad Here is the scenario It is basically a step tracker StepTrackerShakeDetectorService is implemented to restart automatically when app is destroyed using START_STICKY

Android linear acceleration accuracy

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:07:16
问题 I have an app where I poll the sensors for acceleration data and save the XYZ values to a SQL DB. Codewise it is pretty simple: public void onSensorChanged(SensorEvent event) { sensor = event.sensor; int i = sensor.getType(); if (i == MainActivity.TYPE_ACCELEROMETER) { accelerometerMatrix = event.values; } else if (i == MainActivity.TYPE_GYROSCOPE) { gyroscopeMatrix = event.values; } else if (i == MainActivity.TYPE_GRAVITY) { gravityMatrix = event.values; } else if (i == MainActivity.TYPE

Obtaining sensor data for x seconds after onClick of a button

无人久伴 提交于 2019-12-12 03:23:36
问题 I'm still learning Android Development so sorry if this question seems stupid but I'm trying to obtain accelerometer data from the Phone for a limited time only. The goal is for the x-coordinate values from the sensor to be recorded only for about 3 seconds after a button is clicked. public class AccelerometerTestingActivity extends Activity implements SensorEventListener { private SensorManager sensorManager; float x_event[]; @Override public void onCreate(Bundle savedInstanceState){ super