Hi,

I can only speak to question 2, but it seems like you'd want to also
listen for the SENSOR_ACCELEROMETER data, and then look for values
that are above a certain threshold, maybe something like:

if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
   float accel_mag = (values[0]*values[0]+values[1]*values[1]+values[2]
*values[2]);
   if (accel_mag > (3*GRAVITY_EARTH)*(3*GRAVITY_EARTH)) {
      // A force of > 3G was detected.
      // Do something.
   }
}

On Mar 17, 2:02 am, guptha <gjango...@gmail.com> wrote:
> I use OpenIntents to Listen for orientation change  .Everything works
> fine .but i have few doubts
> 1.  I suppose onSensorChanged  is called whenever there is a change in
> orientation
> but contrary to my thought this method is kept calling even there is
> no change in orientation . Yaw ,Roll and Pitch in my sensor simulator
> are at rest.
> 2.  When i shake the mobile violently i have to trigger an event how
> to sense a violent shake
>
>  public void onSensorChanged(int sensor, float[] values){
>          Log.v(TAG,"In onSensorChanged");
>
>         if( sensor == SensorManager.SENSOR_ORIENTATION){
>             setContentView(R.layout.main);
>
>             EditText view_x = (EditText) findViewById(R.id.output);
>             float acelerometerx = values[0];
>             view_x.setText("" + acelerometerx);
>
>             EditText view_y = (EditText) findViewById(R.id.output1);
>             float acelerometery = values[1];
>             view_y.setText("" + acelerometery);
>             long l= System.currentTimeMillis();
>             EditText view_time = (EditText) findViewById
> (R.id.output_ychange);
>             view_time.setText("" +l);
>
>             EditText view_z = (EditText) findViewById(R.id.output2);
>             float acelerometerz = values[2];
>             view_z.setText("" + acelerometerz);
>
>                  }
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to