The Android emulator is currently set up so that it returns that no sensors are available. (you can check this with the SensorsManager method getSensors() which returns 0).
One way to simulate sensors on Android is to use the OpenIntents SensorSimulator: http://www.openintents.org/en/node/6 http://www.openintents.org/en/download This can simulate orientation, accelerometer, and compass sensors, (even the temperature sensor), through the same API that Android uses. One only needs to replace the system's SensorManager by the OpenIntents SensorManager. Please have a look at the samples provided with the download there (OpenGLSensors and ApiDemosSensors) to see how to set things up. Let me know if you have further questions. Peli www.openintents.org On 7 Sep., 15:30, max <[EMAIL PROTECTED]> wrote: > I'm trying to access the sensors under the new 0.9 SDK. But I just > don't get it to work. I distilled the essential code from the API > demos, but registerListener() always returns false and I get this on > logcat: "W/SensorService( 46): could not enable sensor 1". This is > the code: > > public class TestActivity extends Activity { > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > mSensorManager = > (SensorManager)getSystemService(Context.SENSOR_SERVICE); > setContentView(R.layout.main); > } > > @Override > protected void onResume() > { > super.onResume(); > mSensorManager.registerListener(mListener, > SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_GAME); > } > > @Override > protected void onStop() > { > mSensorManager.unregisterListener(mListener); > super.onStop(); > } > > private SensorManager mSensorManager; > private final SensorListener mListener = new SensorListener() { > public void onSensorChanged(int sensor, float[] values) { > Log.i("*****","SENSOR CHANGED"); > } > }; > > > > }- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

