List of usage examples for android.hardware SensorManager SENSOR_DELAY_GAME
int SENSOR_DELAY_GAME
To view the source code for android.hardware SensorManager SENSOR_DELAY_GAME.
Click Source Link
From source file:pl.mrwojtek.sensrec.app.SamplingPeriodDialog.java
public static int getSamplingPosition(long delay) { if (delay == SensorManager.SENSOR_DELAY_NORMAL) { return POSITION_NORMAL; } else if (delay == SensorManager.SENSOR_DELAY_UI) { return POSITION_UI; } else if (delay == SensorManager.SENSOR_DELAY_GAME) { return POSITION_GAME; } else if (delay == SensorManager.SENSOR_DELAY_FASTEST) { return POSITION_FASTEST; } else {/*from w ww. j a v a 2 s. c o m*/ return POSITION_CUSTOM; } }
From source file:com.nikhilnayak.games.octoshootar.beta.SensorDelayDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Sensor Delay"); final ArrayList<String> sensorDelayString = new ArrayList<String>(); sensorDelayString.add("Delay Fastest"); sensorDelayString.add("Delay Game"); sensorDelayString.add("Delay Ui"); sensorDelayString.add("Delay Normal"); final ArrayList<Integer> sensorDelayInteger = new ArrayList<Integer>(); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_FASTEST); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_GAME); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_UI); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_NORMAL); final SharedPreferences sharedPreferences = getActivity() .getSharedPreferences(BetaUtils.KEY_SHARED_PREFERENCES, Context.MODE_PRIVATE); final SharedPreferences.Editor sharedPreferencesEditor = sharedPreferences.edit(); int currentSensorDelayIndex = sensorDelayInteger .indexOf(sharedPreferences.getInt(BetaUtils.KEY_SENSOR_DELAY, SensorManager.SENSOR_DELAY_GAME)); builder.setSingleChoiceItems(sensorDelayString.toArray(new String[] {}), currentSensorDelayIndex, new DialogInterface.OnClickListener() { @Override//w ww. ja va 2 s . c o m public void onClick(DialogInterface dialog, int which) { sharedPreferencesEditor.putInt(BetaUtils.KEY_SENSOR_DELAY, sensorDelayInteger.get(which)); } }); builder.setPositiveButton(R.string.craft_dialog_fragment_ok_response, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sharedPreferencesEditor.commit(); } }); return builder.create(); }
From source file:com.intel.xdk.accelerometer.Accelerometer.java
@JavascriptInterface public void start(int time) { mTime = time;//ww w . ja va 2 s . c o m if (!started) { sensorManager.registerListener(this, SensorManager.SENSOR_ACCELEROMETER, SensorManager.SENSOR_DELAY_GAME); started = true; } }
From source file:com.example.android.camera2video.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); if (null == savedInstanceState) { getFragmentManager().beginTransaction().replace(R.id.container, Camera2VideoFragment.newInstance()) .commit();/*from w w w . j a v a 2 s. c om*/ } mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, TAG_PERMISSION_FINE_LOCATION); } else { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0f, this); } mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccSensor, SensorManager.SENSOR_DELAY_GAME); // mGraSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); // mSensorManager.registerListener(this, mGraSensor, SensorManager.SENSOR_DELAY_GAME); // mLinSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION); // mSensorManager.registerListener(this, mLinSensor, SensorManager.SENSOR_DELAY_GAME); // mGyrSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); // mSensorManager.registerListener(this, mGyrSensor, SensorManager.SENSOR_DELAY_GAME); mUgySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE_UNCALIBRATED); mSensorManager.registerListener(this, mUgySensor, SensorManager.SENSOR_DELAY_GAME); // mMagSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); // mSensorManager.registerListener(this, mMagSensor, SensorManager.SENSOR_DELAY_GAME); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mPowerManager = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName()); mWakeLock.acquire(); }
From source file:org.cocos2dx.lib.Cocos2dxAccelerometer.java
public void enable() { mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); }
From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java
private void initSensors() { try {//from w w w .j a va 2s .c o m if (sensorManager == null) { sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); } if (sensorAccelerometer == null) { sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); } if (sensorMagnetic == null) { sensorMagnetic = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); } boolean accelSupported = sensorManager.registerListener(this, sensorAccelerometer, SensorManager.SENSOR_DELAY_GAME); // ??Accelerometer?? if (!accelSupported) { sensorManager.unregisterListener(this, sensorAccelerometer); } this.sensorManager.registerListener(this, sensorMagnetic, SensorManager.SENSOR_DELAY_GAME); } catch (Exception ex) { } }
From source file:ch.bfh.sensordataprocessor.sensor.SensorDisplayFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.sensor_view, null); sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); name = (TextView) layout.findViewById(R.id.name); type = (TextView) layout.findViewById(R.id.type); maxRange = (TextView) layout.findViewById(R.id.maxRange); minDelay = (TextView) layout.findViewById(R.id.minDelay); power = (TextView) layout.findViewById(R.id.power); resolution = (TextView) layout.findViewById(R.id.resolution); vendor = (TextView) layout.findViewById(R.id.vendor); version = (TextView) layout.findViewById(R.id.version); accuracy = (TextView) layout.findViewById(R.id.accuracy); timestampLabel = (TextView) layout.findViewById(R.id.timestampLabel); timestamp = (TextView) layout.findViewById(R.id.timestamp); timestampUnits = (TextView) layout.findViewById(R.id.timestampUnits); dataLabel = (TextView) layout.findViewById(R.id.dataLabel); dataUnits = (TextView) layout.findViewById(R.id.dataUnits); xAxis = (TextView) layout.findViewById(R.id.xAxis); xAxisLabel = (TextView) layout.findViewById(R.id.xAxisLabel); yAxis = (TextView) layout.findViewById(R.id.yAxis); yAxisLabel = (TextView) layout.findViewById(R.id.yAxisLabel); zAxis = (TextView) layout.findViewById(R.id.zAxis); zAxisLabel = (TextView) layout.findViewById(R.id.zAxisLabel); singleValue = (TextView) layout.findViewById(R.id.singleValue); cosLabel = (TextView) layout.findViewById(R.id.cosLabel); cos = (TextView) layout.findViewById(R.id.cos); layout.findViewById(R.id.delayFastest).setOnClickListener(new OnClickListener() { @Override/* w ww. j a v a 2 s .c om*/ public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_FASTEST); } }); layout.findViewById(R.id.delayGame).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_GAME); } }); layout.findViewById(R.id.delayNormal).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } }); layout.findViewById(R.id.delayUi).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_UI); } }); return layout; }
From source file:org.dartlang.phonegap.gyroscope.GyroscopeListener.java
/** * Start listening for speed sensor.//from w ww .j a v a2s .c om * * @return status of listener */ private int start() { // If already starting or running, then just return if ((this.status == GyroscopeListener.RUNNING) || (this.status == GyroscopeListener.STARTING)) { return this.status; } this.setStatus(GyroscopeListener.STARTING); // Get gyroscope from sensor manager List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_GYROSCOPE); // If found, then register as listener if ((list != null) && (list.size() > 0)) { this.mSensor = list.get(0); this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_GAME); this.setStatus(GyroscopeListener.STARTING); } else { this.setStatus(GyroscopeListener.ERROR_FAILED_TO_START); this.fail(GyroscopeListener.ERROR_FAILED_TO_START, "No sensors found to register gyroscope listening to."); return this.status; } // Set a timeout callback on the main thread. stopTimeout(); mainHandler = new Handler(Looper.getMainLooper()); mainHandler.postDelayed(mainRunnable, 2000); return this.status; }
From source file:pl.mrwojtek.sensrec.app.SamplingPeriodDialog.java
@Override public void onClick(DialogInterface dialog, int which) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); int position = samplingSpinner.getSelectedItemPosition(); if (position == POSITION_CUSTOM) { try {//from w w w . ja v a 2 s . c om long delay = Long.valueOf(millisecondsEdit.getText().toString()); prefs.edit().putLong(SensorsRecorder.PREF_SAMPLING_PERIOD, delay).apply(); } catch (NumberFormatException ex) { Log.i(TAG, "Unable to save sampling delay: " + ex.getMessage()); } } else if (position == POSITION_NORMAL) { prefs.edit().putLong(SensorsRecorder.PREF_SAMPLING_PERIOD, SensorManager.SENSOR_DELAY_NORMAL).apply(); } else if (position == POSITION_UI) { prefs.edit().putLong(SensorsRecorder.PREF_SAMPLING_PERIOD, SensorManager.SENSOR_DELAY_UI).apply(); } else if (position == POSITION_GAME) { prefs.edit().putLong(SensorsRecorder.PREF_SAMPLING_PERIOD, SensorManager.SENSOR_DELAY_GAME).apply(); } else if (position == POSITION_FASTEST) { prefs.edit().putLong(SensorsRecorder.PREF_SAMPLING_PERIOD, SensorManager.SENSOR_DELAY_FASTEST).apply(); } }
From source file:com.example.casthelloworld.MainActivity.java
/** * Android voice recognition/*from www . j a v a 2 s. c om*/ */ public void enableOrientationListener() { sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_GAME); }