Thank you for the great feedback!

In the mean-time I've updated the documentation here:
http://code.google.com/p/openintents/wiki/SensorSimulator

Yes, a Java Precompiler would indeed come handy in cases like this.
Maybe you can reduce the number of places where you have to comment
out code to a single place, by putting all relevant code into methods
of a single class, and in the five places in your code use if-else
with a final boolean. Then the code in the unused if-branch will be
stripped off completely by the compiler.

For example:
-------------------------
MySensorsClass.init();  // Optionally initialize

if (MySensorsClass.useSensorSimulator) {
  ... time-critical code A ...
} else {
  ... time-critical code B ...
}

// and somewhere else
class MySensorsClass {
    // Either use this block
  /* *+/     // (<- the '+' ensures that this block is commented out)
  static final boolean useSensorSimulator = true;
  static init() {
    call OI code
  }
  static prepareMenus() {
    call OI code
  }
  /* */

  // or use this block
  /*  */    // (<- no '+' here so this block is in use)
  static final boolean useSensorSimulator = false;
  static init() {
    // do nothing
  }
  static prepareMenus() {
    // do nothing
  }
  /* */
}
--------------------

Then it would be just a matter of moving the "+" around from the first
to the second comment block and adding or removing the lib.

Peli

On 9 Sep., 21:40, blindfold <[EMAIL PROTECTED]> wrote:
> Thanks Peli, it works like a charm now! In fact my compass code needed
> no adaptation, but it was very nice to simulate it to make sure. Your
> demo sample was particularly helpful. Great stuff! Before I had just
> not realized that I had to download the documentation bundle rather
> than read the various pieces of online material. Thanks for clarifying
> that.
>
> Regards
>
> Long P.S.: I just wished that the Java language purists would not have
> prevented having a C-like preprocessor (#ifdef, etc) such that I could
> more easily, and with physical certainty, remove all OpenIntents
> traces and dependencies after testing. I prefer physical code
> stripping over any assurances of transparency. Right now I have to
> comment out code in five places. Doable after adding unique searchable
> OpenIntents tags to those various places, but not convenient. This is
> not an OpenIntents problem, of course. I hope that someone will figure
> out how to add a C preprocessor to Eclipse for working with Android.
>
> On Sep 9, 12:52 am, Peli <[EMAIL PROTECTED]> wrote:
>
>
>
> > 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- 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 android-developers@googlegroups.com
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