Sorry, yes I have not updated the old m5 documentation.

Everything is well documented in the samples/ApiDemosSensors though.

You have to replace this:
----------
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
----------
by this:
========
// Before calling any of the Simulator data,
// the Content resolver has to be set !!
Hardware.mContentResolver = getContentResolver();

// Link sensor manager to OpenIntents Sensor simulator
mSensorManager = (SensorManager) new
SensorManagerSimulator((SensorManager)
                              getSystemService(SENSOR_SERVICE));
========

By default this still passes the original sensor values, so to
activate sensors you have to first call (to set the sensor settings):
-------
Intent intent = new Intent(Intent.ACTION_VIEW,
Hardware.Preferences.CONTENT_URI);
startActivity(intent);
---------

and then
---------
// first disable the current sensor
mSensorManager.unregisterListener(mGraphView);

// now connect to simulator
SensorManagerSimulator.connectSimulator();

// now enable the new sensors
mSensorManager.registerListener(mGraphView,
           SensorManager.SENSOR_ACCELEROMETER |
           SensorManager.SENSOR_MAGNETIC_FIELD |
           SensorManager.SENSOR_ORIENTATION,
           SensorManager.SENSOR_DELAY_FASTEST);
---------

Then just implement the android SensorListener (there is no OI
counterpart necessary).

I hope this helps (and I hope I will find time to update the outdated
documentation - sorry for the confusion).

Peli

On 8 Sep., 23:18, blindfold <[EMAIL PROTECTED]> wrote:
> Hi Peli,
>
> There are still a few things to update in the documentation 
> athttp://code.google.com/p/openintents/wiki/SensorSimulator
> such as
>
> Intent.VIEW_ACTION => Intent.ACTION_VIEW
>
> and the requirement to have in the manifest
>
> <uses-permission android:name="android.permission.INTERNET"/>
>
> but otherwise things mostly worked very nicely. However,
>
> SensorManager sensorManager = (SensorManager)
> getSystemService(Context.SENSOR_SERVICE);
> ok = sensorManager.registerListener(sensorListener,
>          SensorManager.SENSOR_ORIENTATION,
>          SensorManager.SENSOR_DELAY_NORMAL);
>
> for me still returns false for "ok". Do I need to replace these by
> some OpenIntents equivalents?
> What are the OpenIntents counterparts of
>
> import android.hardware.SensorListener;
> import android.hardware.SensorManager;
>
> Thanks
>
> On Sep 7, 9:06 am, Peli <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi blindfold,
>
> > > How can I have a simple switch (in Eclipse) during
> > > the development cycle such that I can easily build with and without
> > > the OpenIntents Sensor simulator?
>
> > By default, the SensorManagerSimulator transparently passes requests
> > to Android's internal sensor, so if you remove the line
> > requiresOpenIntents() and deactivate the menus for Settings and
> > Connect, you have your original functionality back. (even though OI
> > code remains that increases your apk file size).
>
> > If you completely want to get rid of OI code, I guess there is no way
> > other than manually removing the lib from your project and commenting
> > out the two additional OI code sections in your code - which is
> > quickly done.
>
> > Maybe you can set up two projects in Eclipse: One is your original
> > project, and the second one is your test project that depends on the
> > first project, but additionally contains the lib. I haven't actually
> > tried this, and I don't know if it is worth the effort, given that one
> > can easily add lib + code section in a few minutes and remove them
> > (remove lib and comment out code) before distribution in a few seconds
> > without leaving any traces.
>
> > Let me know if you have further questions.
>
> > Peli- 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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to