Example usage for android.hardware SensorManager SENSOR_DELAY_NORMAL

List of usage examples for android.hardware SensorManager SENSOR_DELAY_NORMAL

Introduction

In this page you can find the example usage for android.hardware SensorManager SENSOR_DELAY_NORMAL.

Prototype

int SENSOR_DELAY_NORMAL

To view the source code for android.hardware SensorManager SENSOR_DELAY_NORMAL.

Click Source Link

Document

rate (default) suitable for screen orientation changes

Usage

From source file:org.zywx.wbpalmstar.plugin.uexaudio.EUExAudio.java

public static void onActivityReStart(Context context) {
    BDebug.i(tag, "onActivityReStart");
    if (sensorEventListener != null) {
        SensorManager mSensorManager = (SensorManager) context.getApplicationContext()
                .getSystemService(Context.SENSOR_SERVICE);
        Sensor mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
        mSensorManager.registerListener(sensorEventListener, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }/*  w w  w . j  av  a2s  . c  o  m*/
}

From source file:org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedDataReader.java

public SpeedDataReader(Context context) {
    ctx = context;/*w w w. j ava 2 s .com*/
    SharedPreferences sharedPreferences = ctx.getSharedPreferences(SupportedSensors.SELECTED_SENSORS,
            Context.MODE_MULTI_PROCESS);
    Set<String> selectedSet = sharedPreferences.getStringSet(SupportedSensors.SELECTED_SENSORS_BY_USER, null);
    mSensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
    selectedSensorList(selectedSet);
    for (Sensor sensor : sensorList) {
        mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
    }

    LocalBroadcastManager.getInstance(ctx).registerReceiver(mMessageReceiver, new IntentFilter("speedUpdate"));

}

From source file:org.apache.cordova.TempListener.java

public void start() {
    @SuppressWarnings("deprecation")
    List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_TEMPERATURE);
    if (list.size() > 0) {
        this.mSensor = list.get(0);
        this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }/*www. ja v  a  2 s .  c om*/
}

From source file:eu.geopaparazzi.core.ui.dialogs.GpsInfoDialogFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    SensorManager sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    orientationSensor = new OrientationSensor(sensorManager, null);
    orientationSensor.register(getActivity(), SensorManager.SENSOR_DELAY_NORMAL);

    gpsServiceBroadcastReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            onGpsServiceUpdate(intent);//from   w w  w. jav  a2s . c o m
        }
    };
    GpsServiceUtilities.registerForBroadcasts(getActivity(), gpsServiceBroadcastReceiver);
    GpsServiceUtilities.triggerBroadcast(getActivity());
}

From source file:rp.soi.dmsd.notextingwhilewalking.DetectedActivitiesIntentService.java

/**
 * Handles incoming intents./*from w  ww  . ja v a 2s  .c o  m*/
 * @param intent The Intent is provided (inside a PendingIntent) when requestActivityUpdates()
 *               is called.
 */
@Override
protected void onHandleIntent(Intent intent) {
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mOrientation = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    mSensorManager.registerListener(this, mOrientation, SensorManager.SENSOR_DELAY_NORMAL);
    PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);

    ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
    Intent localIntent = new Intent(rp.soi.dmsd.notextingwhilewalking.Constants.BROADCAST_ACTION);

    // Get the list of the probable activities associated with the current state of the
    // device. Each activity is associated with a confidence level, which is an int between
    // 0 and 100.
    ArrayList<DetectedActivity> detectedActivities = (ArrayList) result.getProbableActivities();

    // Log each activity.
    Log.i(TAG, "activities detected");
    for (DetectedActivity da : detectedActivities) {
        Log.i(TAG, rp.soi.dmsd.notextingwhilewalking.Constants.getActivityString(getApplicationContext(),
                da.getType()) + " " + da.getConfidence() + "%");
        // trigger a notification if the walking activity has a confidence of > 50%

        //float[] xyz = mSensorManager.getOrientation();

        if (da.getType() == DetectedActivity.WALKING && da.getConfidence() > 15) {

            // For API 20 and higher
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Log.i(TAG, "Android version is HIGHER than 20 ");
                if (powerManager.isInteractive()) {
                    Log.i(TAG, "Screen is ON");
                    if (isPhoneFacingUp) {
                        Log.i(TAG, "Phone is facing UP.");
                        createNotification(true);
                    } else {
                        Log.i(TAG, "Phone is facing DOWN.");
                    }
                } else {
                    Log.i(TAG, "Screen is OFF");
                }
            } else {
                Log.i(TAG, "Android version is LOWER than 20 ");
                if (powerManager.isScreenOn()) {
                    Log.i(TAG, "Screen is ON");
                    if (isPhoneFacingUp) {
                        Log.i(TAG, "Phone is facing UP.");
                        createNotification(true);
                    } else {
                        Log.i(TAG, "Phone is facing DOWN.");
                    }
                } else {
                    Log.i(TAG, "Screen is OFF");
                }
            }
        }

    }

    // Broadcast the list of detected activities.
    localIntent.putExtra(Constants.ACTIVITY_EXTRA, detectedActivities);
    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
}

From source file:de.sopamo.triangula.android.GameActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App.setActivityContext(this);

    Bundle b = getIntent().getExtras();/*  w  ww  . ja va2  s  . c  o m*/
    if (b != null) {
        level = (Level) b.get("level");
    } else {
        level = new Level1();
    }

    mGameGlSurfaceView = new GameGLSurfaceView(this);

    setContentView(R.layout.main);
    LinearLayout ll = (LinearLayout) findViewById(R.id.layout_main);
    ll.addView(mGameGlSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    status = (TextView) findViewById(R.id.tv_status);
    // Disable hiding for debug
    if (true) {
        status.setVisibility(View.GONE);
    }

    SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE);
    sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_NORMAL);

    mGameGlSurfaceView.init();

}

From source file:com.example.android.camera2basic.CameraActivity.java

@Override
protected void onResume() {
    super.onResume();
    mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
}

From source file:com.achep.acdisplay.ui.fragments.PocketFragment.java

@Override
public void onResume() {
    super.onResume();
    if (mProximityAvailable) {
        mSensorManager.registerListener(this, mProximitySensor, SensorManager.SENSOR_DELAY_NORMAL);
        mFirstChange = true;/*from  w  w  w .ja v  a 2s.c  om*/
        mNear = false;
    }
}

From source file:edu.cmu.sv.trailscribe.view.MapsActivity.java

@Override
protected void onResume() {
    super.onResume();
    mSensorManager.registerListener(this, mOrientationSensor, SensorManager.SENSOR_DELAY_NORMAL);
}

From source file:com.mruddy.devdataviewer.SensorFragment.java

/**
 * @see android.support.v4.app.Fragment#onResume()
 *//*from w w w . j a va  2s.  c o  m*/
@Override
public void onResume() {
    super.onResume();
    this.accelerometerTextView = (TextView) this.getActivity().findViewById(R.id.textViewAccelerometer);
    this.gpsTextView = (TextView) this.getActivity().findViewById(R.id.textViewGPS);
    this.sensorManager = (SensorManager) this.getActivity().getSystemService(Context.SENSOR_SERVICE);
    final Sensor accelerometerSensor = this.sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (null != accelerometerSensor) {
        this.accelerometerTextView.setText("waiting for data...");
        this.sensorManager.registerListener(this, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
    } else {
        this.accelerometerTextView.setText("accelerometer not found");
    }
    this.locationManager = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE);
    this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}