use of android.support.annotation.RequiresPermission in project android-vision by googlesamples.
the class CameraSourcePreview method startIfReady.
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
if (mStartRequested && mSurfaceAvailable) {
mCameraSource.start(mSurfaceView.getHolder());
if (mOverlay != null) {
Size size = mCameraSource.getPreviewSize();
int min = Math.min(size.getWidth(), size.getHeight());
int max = Math.max(size.getWidth(), size.getHeight());
if (isPortraitMode()) {
// Swap width and height sizes when in portrait, since it will be rotated by
// 90 degrees
mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
} else {
mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
}
mOverlay.clear();
}
mStartRequested = false;
}
}
use of android.support.annotation.RequiresPermission in project LshUtils by SenhLinsh.
the class LshAppUtils method isAppOnForeground.
/**
* 判断App是否在前台运行
* 注意: 该方法是判断APP是否处于栈顶, 处于栈顶但是是关闭屏幕的情况下依然返回true
*/
@RequiresPermission(Manifest.permission.GET_TASKS)
public boolean isAppOnForeground() {
ActivityManager activityManager = (ActivityManager) LshApplicationUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasksInfo = activityManager.getRunningTasks(1);
if (tasksInfo.size() > 0) {
// 应用程序位于堆栈的顶层
if (getPackageName().equals(tasksInfo.get(0).topActivity.getPackageName())) {
return true;
}
}
return false;
}
Aggregations