Java Code Examples for android.hardware.SensorManager#SENSOR_DELAY_UI
The following examples show how to use
android.hardware.SensorManager#SENSOR_DELAY_UI .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Preferences.java From ShaderEditor with MIT License | 6 votes |
private static int parseSensorDelay(String s, int preset) { if (s == null) { return preset; } switch (s) { case "Fastest": return SensorManager.SENSOR_DELAY_FASTEST; case "Game": return SensorManager.SENSOR_DELAY_GAME; case "Normal": return SensorManager.SENSOR_DELAY_NORMAL; case "UI": return SensorManager.SENSOR_DELAY_UI; } return preset; }
Example 2
Source File: MainActivity.java From programming with GNU General Public License v3.0 | 5 votes |
private void addOrientationListener() { listener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { public void onOrientationChanged(int orientation) { if ((orientation >= 230 && orientation <= 290) || (orientation >= 70 && orientation <= 90)) { portrait.setText("True"); } } }; if (listener.canDetectOrientation()) listener.enable(); }
Example 3
Source File: PCustomSensorManager.java From PHONK with GNU General Public License v3.0 | 5 votes |
@PhonkMethod(description = "Set the speed of the sensor 'slow', 'normal', 'fast'", example = "") @PhonkMethodParam(params = {"speed=['slow', 'normal', 'fast']"}) public void sensorSpeed(String speed) { if (speed.equals("slow")) { this.speed = SensorManager.SENSOR_DELAY_UI; } else if (speed.equals("fast")) { this.speed = SensorManager.SENSOR_DELAY_FASTEST; } else { this.speed = SensorManager.SENSOR_DELAY_NORMAL; } }
Example 4
Source File: MainActivity.java From Android-Application with GNU General Public License v3.0 | 4 votes |
LayoutRotateOnOrientation(){ super(MainActivity.this, SensorManager.SENSOR_DELAY_UI); display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); }
Example 5
Source File: CameraActivity.java From Eye-blink-detector with MIT License | 4 votes |
private void showCameraScannerOverlay() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { View decorView = getWindow().getDecorView(); // Hide the status bar. int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); // Remember that you should never show the action bar if the // status bar is hidden, so hide that too if necessary. ActionBar actionBar = getActionBar(); if (null != actionBar) { actionBar.hide(); } } try { mGuideFrame = new Rect(); mFrameOrientation = ORIENTATION_PORTRAIT; if (getIntent().getBooleanExtra(PRIVATE_EXTRA_CAMERA_BYPASS_TEST_MODE, false)) { if (!this.getPackageName().contentEquals("io.card.development")) { throw new IllegalStateException("Illegal access of private extra"); } // use reflection here so that the tester can be safely stripped for release // builds. Class<?> testScannerClass = Class.forName("io.card.payment.CardScannerTester"); Constructor<?> cons = testScannerClass.getConstructor(this.getClass(), Integer.TYPE); mCardScanner = (FaceScanner) cons.newInstance(new Object[] { this, mFrameOrientation }); } else { mCardScanner = new FaceScanner(this, mFrameOrientation); } mCardScanner.prepareScanner(); setPreviewLayout(); orientationListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { @Override public void onOrientationChanged(int orientation) { doOrientationChange(orientation); } }; } catch (Exception e) { handleGeneralExceptionError(e); } }
Example 6
Source File: MainActivity.java From PixaToon with GNU General Public License v3.0 | 4 votes |
/** * OnCreate method * @param savedInstanceState */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); checkAndRequestPermissions(); // // Hide navigation buttons and go full-screen, for devices without hardware navigation buttons // getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN // | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); setContentView(R.layout.activity_main); mFilterManager = FilterManager.getInstance(); mCameraViewerFragment = new CameraViewerFragment(); mPictureViewerFragment = new PictureViewerFragment(); mFilterSelectorFragment = new FilterSelectorFragment(); mOpenPictureBtn = (ImageButton) findViewById(R.id.openPictureBtn); mSelectFilterBtn = (ImageButton) findViewById(R.id.selectFilterBtn); mOpenCameraBtn = (ImageButton) findViewById(R.id.openCameraBtn); mConfigFilterBtn = (ImageButton) findViewById(R.id.configFilterBtn); mCapturePictureBtn = (ImageButton) findViewById(R.id.capturePictureBtn); mMsgTextView = (TextView) findViewById(R.id.msgTextView); mHandler = new Handler(); // Register onClick listeners mOpenPictureBtn.setOnClickListener(this); mSelectFilterBtn.setOnClickListener(this); mOpenCameraBtn.setOnClickListener(this); mConfigFilterBtn.setOnClickListener(this); mCapturePictureBtn.setOnClickListener(this); findViewById(R.id.filterViewer).setOnClickListener(this); // Load sketch texture loadSketchTexture(getApplicationContext().getResources(), R.drawable.sketch_texture); // Set camera viewer as default getFragmentManager() .beginTransaction() .add(R.id.filterViewer, mCameraViewerFragment) .commit(); /** * Device orientation listener implementation to appropriately rotate button and filter icons on orientation change */ mOrientationListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { @Override public void onOrientationChanged(int orientation) { if(isOrientationLandscape(orientation) && mOrientation == Configuration.ORIENTATION_PORTRAIT) { mOrientation = Configuration.ORIENTATION_LANDSCAPE; mCapturePictureBtn.setRotation(90); mOpenPictureBtn.setRotation(90); mOpenCameraBtn.setRotation(90); mSelectFilterBtn.setRotation(90); mConfigFilterBtn.setRotation(90); mMsgTextView.setRotation(90); if(mFilterSelectorFragment.isVisible()) mFilterSelectorFragment.changeOrientation(mOrientation); } else if(isOrientationPortrait(orientation) && mOrientation == Configuration.ORIENTATION_LANDSCAPE) { mOrientation = Configuration.ORIENTATION_PORTRAIT; mCapturePictureBtn.setRotation(0); mOpenPictureBtn.setRotation(0); mOpenCameraBtn.setRotation(0); mSelectFilterBtn.setRotation(0); mConfigFilterBtn.setRotation(0); mMsgTextView.setRotation(0); if(mFilterSelectorFragment.isVisible()) mFilterSelectorFragment.changeOrientation(mOrientation); } } }; }
Example 7
Source File: BarcodeCaptureActivity.java From google-authenticator-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // On API 19+ devices, we make the status bar become transparent. In older devices, we simply // remove the status bar. if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); // On API 21+ we need to set the status bar color to transparent color instead of using flag // FLAG_TRANSLUCENT_STATUS as in API 19, 20 to make the the status bar transparent. if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(Color.TRANSPARENT); } else { getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } } else { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } mStartFromAddAccountActivity = getIntent() .getBooleanExtra(INTENT_EXTRA_START_FROM_ADD_ACCOUNT, false); setContentView(R.layout.barcode_capture_activity); mCameraSourcePreview = (CameraSourcePreview) findViewById(R.id.camera_source_preview); mGraphicOverlay = (GraphicOverlay) findViewById(R.id.graphic_overlay); mCurrentRotation = getWindowManager().getDefaultDisplay().getRotation(); mOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { @Override public void onOrientationChanged(int i) { if (i == ORIENTATION_UNKNOWN) { return; } int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (mCurrentRotation != rotation) { // Orientation changed, refresh camera. mCurrentRotation = rotation; if (mCameraSourcePreview != null) { mCameraSourcePreview.stop(); mCameraSourcePreview.release(); } createCameraSource(); startCameraSource(); } } }; if (mOrientationEventListener.canDetectOrientation() == true) { mOrientationEventListener.enable(); } else { mOrientationEventListener.disable(); } // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. if (mPermissionRequestor.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { createCameraSource(); } else { requestCameraPermission(); } }
Example 8
Source File: WebRTCDemo.java From webrtc-app-mono with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); populateCameraOrientations(); setContentView(R.layout.tabhost); IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().compareTo(Intent.ACTION_HEADSET_PLUG) == 0) { int state = intent.getIntExtra("state", 0); Log.v(TAG, "Intent.ACTION_HEADSET_PLUG state: " + state + " microphone: " + intent.getIntExtra("microphone", 0)); if (voERunning) { routeAudio(state == 0 && cbEnableSpeaker.isChecked()); } } } }; registerReceiver(receiver, receiverFilter); mTabHost = getTabHost(); // Main tab mTabSpecVideo = mTabHost.newTabSpec("tab_video"); mTabSpecVideo.setIndicator("Main"); mTabSpecVideo.setContent(R.id.tab_video); mTabHost.addTab(mTabSpecVideo); // Shared config tab mTabHost = getTabHost(); mTabSpecConfig = mTabHost.newTabSpec("tab_config"); mTabSpecConfig.setIndicator("Settings"); mTabSpecConfig.setContent(R.id.tab_config); mTabHost.addTab(mTabSpecConfig); TabSpec mTabv; mTabv = mTabHost.newTabSpec("tab_vconfig"); mTabv.setIndicator("Video"); mTabv.setContent(R.id.tab_vconfig); mTabHost.addTab(mTabv); TabSpec mTaba; mTaba = mTabHost.newTabSpec("tab_aconfig"); mTaba.setIndicator("Audio"); mTaba.setContent(R.id.tab_aconfig); mTabHost.addTab(mTaba); int childCount = mTabHost.getTabWidget().getChildCount(); for (int i = 0; i < childCount; i++) { mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 50; } orientationListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { public void onOrientationChanged (int orientation) { if (orientation != ORIENTATION_UNKNOWN) { currentDeviceOrientation = orientation; compensateCameraRotation(); } } }; orientationListener.enable (); // Create a folder named webrtc in /scard for debugging webrtcDebugDir = Environment.getExternalStorageDirectory().toString() + webrtcName; File webrtcDir = new File(webrtcDebugDir); if (!webrtcDir.exists() && webrtcDir.mkdir() == false) { Log.v(TAG, "Failed to create " + webrtcDebugDir); } else if (!webrtcDir.isDirectory()) { Log.v(TAG, webrtcDebugDir + " exists but not a folder"); webrtcDebugDir = null; } startMain(); if (AUTO_CALL_RESTART_DELAY_MS > 0) startOrStop(); }
Example 9
Source File: XSensorManager.java From XPrivacy with GNU General Public License v3.0 | 4 votes |
@Override protected void before(XParam param) throws Throwable { switch (mMethod) { case getDefaultSensor: if (isRestricted(param)) param.setResult(null); else if (param.args.length > 0 && param.args[0] instanceof Integer) if (isRestricted(param, (Integer) param.args[0])) param.setResult(null); break; case getSensorList: if (isRestricted(param)) param.setResult(new ArrayList<Sensor>()); else if (param.args.length > 0 && param.args[0] instanceof Integer) if (isRestricted(param, (Integer) param.args[0])) param.setResult(new ArrayList<Sensor>()); break; case registerListener: if (param.args.length > 2 && param.args[1] instanceof Sensor && param.args[2] instanceof Integer) { int type = ((Sensor) param.args[1]).getType(); if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) { int rateUs = (Integer) param.args[2]; // http://developer.android.com/guide/topics/sensors/sensors_overview.html if (rateUs == SensorManager.SENSOR_DELAY_NORMAL) return; // 200,000 us else if (rateUs == SensorManager.SENSOR_DELAY_UI) return; // 60,000 us else if (rateUs == SensorManager.SENSOR_DELAY_GAME) return; // 20,000 us else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST) ; // 0 us if (rateUs < cMaxRateUs) // 10,000 us if (isRestricted(param)) param.args[2] = cMaxRateUs; } } break; } }
Example 10
Source File: WindowOrientationListener.java From android_9.0.0_r45 with Apache License 2.0 | 2 votes |
/** * Creates a new WindowOrientationListener. * * @param context for the WindowOrientationListener. * @param handler Provides the Looper for receiving sensor updates. */ public WindowOrientationListener(Context context, Handler handler) { this(context, handler, SensorManager.SENSOR_DELAY_UI); }