I'm trying to read a few sensors with the Samsung Galaxy Tab GT-P1000, and they seem to clog the processor pretty much with respect to the applications I used.
As a test, I created a short program that implements a SensorEventListener for an accelerometer sensor, but does nothing with the sensor readings:
public class SensorTestActivity extends Activity implements SensorEventListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SensorManager oSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); oSensorManager.registerListener(this, oSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) {
This leads to 10% permanent CPU usage during debugging (i.e. my device is connected to my PC) and 5% usage, but I donβt. If I use SENSOR_DELAY_FASTEST, the use of skyrockets will be constant 30% while I am debugging, and 20% until I will.
This creates a serious problem when I want to use several sensors, because all of them have a high level of CPU usage and without data processing. I used Compass apps from the Android Market, and none of them are using more than 5% of the processor at a given time, so I feel like I am missing something obviously obvious, but I can not find anyone else with the same problem .
I did not edit the manifest file or layout for this application - this is the default template made by Eclipse, and I added the Sensor.
UPDATE: my CPU usage read method is corrupted because I used the task manager to measure it. My application does not stop sensors using onPause when the task manager opens, while most other applications will do this.
source share