android.view.IRotationWatcher Java Examples
The following examples show how to use
android.view.IRotationWatcher.
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: LegacySensorManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public LegacySensorManager(SensorManager sensorManager) { mSensorManager = sensorManager; synchronized (SensorManager.class) { if (!sInitialized) { sWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService("window")); if (sWindowManager != null) { // if it's null we're running in the system process // which won't get the rotated values try { sRotation = sWindowManager.watchRotation( new IRotationWatcher.Stub() { public void onRotationChanged(int rotation) { LegacySensorManager.onRotationChanged(rotation); } }, DEFAULT_DISPLAY); } catch (RemoteException e) { } } } } }
Example #2
Source File: PopupWindowManager.java From Noyze with Apache License 2.0 | 6 votes |
/** Register an {@link IRotationWatcher} with IWindowManager. */ protected static boolean watchRotations(IRotationWatcher watcher, final boolean watch) { // NOTE: removeRotationWatcher is only available on Android 4.3 (API 18) and 4.4 (API 19 & 20). final String methodName = ((watch) ? "watchRotation" : "removeRotationWatcher" ); final IInterface mWM = getIWindowManager(); if (null == mWM) return false; try { Method mMethod = mWM.getClass().getDeclaredMethod( methodName, new Class[]{ IRotationWatcher.class }); if (mMethod == null) return false; mMethod.setAccessible(true); mMethod.invoke(mWM, watcher); return true; } catch (Throwable t) { Log.e(TAG, "Cannot register " + IRotationWatcher.class.getSimpleName() , t); return false; } }
Example #3
Source File: PopupWindowManager.java From Noyze with Apache License 2.0 | 6 votes |
/** Register an {@link IRotationWatcher} with IWindowManager. */ protected static boolean watchRotations(IRotationWatcher watcher, final boolean watch) { // NOTE: removeRotationWatcher is only available on Android 4.3 (API 18) and 4.4 (API 19 & 20). final String methodName = ((watch) ? "watchRotation" : "removeRotationWatcher" ); final IInterface mWM = getIWindowManager(); if (null == mWM) return false; try { Method mMethod = mWM.getClass().getDeclaredMethod( methodName, new Class[]{ IRotationWatcher.class }); if (mMethod == null) return false; mMethod.setAccessible(true); mMethod.invoke(mWM, watcher); return true; } catch (Throwable t) { Log.e(TAG, "Cannot register " + IRotationWatcher.class.getSimpleName() , t); return false; } }
Example #4
Source File: DisplayUtil.java From DroidCast with Apache License 2.0 | 5 votes |
void setRotateListener(RotateListener listener) { try { Class<?> clazz = iWindowManager.getClass(); IRotationWatcher watcher = new IRotationWatcher.Stub() { @Override public void onRotationChanged(int rotation) throws RemoteException { if (listener != null) { listener.onRotate(rotation); } } }; try { clazz.getMethod("watchRotation", IRotationWatcher.class, int.class) .invoke(iWindowManager, watcher, Display.DEFAULT_DISPLAY); // 26+ } catch (NoSuchMethodException ex) { clazz.getMethod("watchRotation", IRotationWatcher.class) .invoke(iWindowManager, watcher); } } catch (Exception e) { e.printStackTrace(); } }