List of usage examples for android.view Display DEFAULT_DISPLAY
int DEFAULT_DISPLAY
To view the source code for android.view Display DEFAULT_DISPLAY.
Click Source Link
From source file:com.brotherpowers.cameraview.ViewCompat2.java
/** * Gets the logical display to which the view's window has been attached. * * @param view The view.//from w w w .j ava2s . c o m * @return The logical display, or null if the view is not currently attached to a window. */ public static Display getDisplay(@NonNull View view) { if (Build.VERSION.SDK_INT >= 17) { return view.getDisplay(); } return ViewCompat.isAttachedToWindow(view) ? DisplayManagerCompat.getInstance(view.getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null; }
From source file:org.chromium.ChromeSystemDisplay.java
private JSONObject getDisplayInfo(final Display display) throws JSONException { JSONObject displayInfo = new JSONObject(); displayInfo.put("id", Integer.toString(display.getDisplayId())); try {//from w ww. ja va 2s . c o m displayInfo.put("name", display.getName()); } catch (NoSuchMethodError e) { displayInfo.put("name", "Default"); } displayInfo.put("isPrimary", display.getDisplayId() == android.view.Display.DEFAULT_DISPLAY); displayInfo.put("dpiX", getDpiX(display)); displayInfo.put("dpiY", getDpiY(display)); displayInfo.put("rotation", getRotation(display)); displayInfo.put("bounds", getBounds(display)); displayInfo.put("overscan", getOverscan()); displayInfo.put("workArea", getWorkArea(display)); // mirroringSourceId, isInternal and isEnabled cannot be retrieved at this moment. return displayInfo; }
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@SuppressLint("RtlHardcoded") @SuppressWarnings("deprecation") @Override// w w w . ja v a 2 s.co m protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.CONTEXT_MENU_APPEARING")); boolean isNonAppMenu = !getIntent().hasExtra("package_name") && !getIntent().hasExtra("app_name"); showStartMenu = getIntent().getBooleanExtra("launched_from_start_menu", false); isStartButton = isNonAppMenu && getIntent().getBooleanExtra("is_start_button", false); isOverflowMenu = isNonAppMenu && getIntent().getBooleanExtra("is_overflow_menu", false); contextMenuFix = getIntent().hasExtra("context_menu_fix"); // Determine where to position the dialog on screen WindowManager.LayoutParams params = getWindow().getAttributes(); DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); int statusBarHeight = 0; int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) statusBarHeight = getResources().getDimensionPixelSize(resourceId); if (showStartMenu) { int x = getIntent().getIntExtra("x", 0); int y = getIntent().getIntExtra("y", 0); int offset = getResources().getDimensionPixelSize( isOverflowMenu ? R.dimen.context_menu_offset_overflow : R.dimen.context_menu_offset); switch (U.getTaskbarPosition(this)) { case "bottom_left": case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x; params.y = display.getHeight() - y - offset; break; case "bottom_right": case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = display.getHeight() - y - offset; break; case "top_left": case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x; params.y = y - offset + statusBarHeight; break; case "top_right": case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = y - offset + statusBarHeight; break; } } else { LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); int x = getIntent().getIntExtra("x", display.getWidth()); int y = getIntent().getIntExtra("y", display.getHeight()); int offset = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(this)) { case "bottom_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "bottom_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "top_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; case "top_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; } } params.width = getResources().getDimensionPixelSize(R.dimen.context_menu_width); params.dimAmount = 0; getWindow().setAttributes(params); View view = findViewById(android.R.id.list); if (view != null) view.setPadding(0, 0, 0, 0); generateMenu(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.farmerbb.taskbar.START_MENU_APPEARING"); intentFilter.addAction("com.farmerbb.taskbar.DASHBOARD_APPEARING"); LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, intentFilter); }
From source file:com.farmerbb.taskbar.activity.DashboardActivity.java
@SuppressWarnings("deprecation") @Override// ww w . j a v a 2 s .co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); contextMenuFix = getIntent().hasExtra("context_menu_fix"); // Detect outside touches, and finish the activity when one is detected getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); setContentView(R.layout.incognito); LinearLayout layout = (LinearLayout) findViewById(R.id.incognitoLayout); layout.setLayoutParams(new FrameLayout.LayoutParams(display.getWidth(), display.getHeight())); LocalBroadcastManager.getInstance(this).registerReceiver(addWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.ADD_WIDGET_REQUESTED")); LocalBroadcastManager.getInstance(this).registerReceiver(removeWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.REMOVE_WIDGET_REQUESTED")); LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, new IntentFilter("com.farmerbb.taskbar.DASHBOARD_DISAPPEARING")); if (!DashboardHelper.getInstance().isDashboardOpen()) finish(); }
From source file:com.farmerbb.taskbar.adapter.StartMenuAdapter.java
@SuppressWarnings("deprecation") private void openContextMenu(final AppEntry entry, final int[] location) { LocalBroadcastManager.getInstance(getContext()) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); new Handler().postDelayed(() -> { SharedPreferences pref = U.getSharedPreferences(getContext()); Intent intent = null;// w w w . ja va 2 s .co m switch (pref.getString("theme", "light")) { case "light": intent = new Intent(getContext(), ContextMenuActivity.class); break; case "dark": intent = new Intent(getContext(), ContextMenuActivityDark.class); break; } if (intent != null) { intent.putExtra("package_name", entry.getPackageName()); intent.putExtra("app_name", entry.getLabel()); intent.putExtra("component_name", entry.getComponentName()); intent.putExtra("user_id", entry.getUserId(getContext())); intent.putExtra("launched_from_start_menu", true); intent.putExtra("x", location[0]); intent.putExtra("y", location[1]); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && FreeformHackHelper.getInstance().isInFreeformWorkspace()) { DisplayManager dm = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); if (intent != null && U.isOPreview()) intent.putExtra("context_menu_fix", true); getContext().startActivity(intent, U.getActivityOptions(ApplicationType.CONTEXT_MENU) .setLaunchBounds(new Rect(0, 0, display.getWidth(), display.getHeight())).toBundle()); } else getContext().startActivity(intent); }, shouldDelay() ? 100 : 0); }
From source file:com.android.tv.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG)//from w w w . j ava 2 s.co m Log.d(TAG, "onCreate()"); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M && !PermissionUtils.hasAccessAllEpg(this)) { Toast.makeText(this, R.string.msg_not_supported_device, Toast.LENGTH_LONG).show(); finish(); return; } boolean skipToShowOnboarding = getIntent().getAction() == Intent.ACTION_VIEW && TvContract.isChannelUriForPassthroughInput(getIntent().getData()); if (Features.ONBOARDING_EXPERIENCE.isEnabled(this) && OnboardingUtils.needToShowOnboarding(this) && !skipToShowOnboarding && !TvCommonUtils.isRunningInTest()) { // TODO: The onboarding is turned off in test, because tests are broken by the // onboarding. We need to enable the feature for tests later. startActivity(OnboardingActivity.buildIntent(this, getIntent())); finish(); return; } TvApplication tvApplication = (TvApplication) getApplication(); tvApplication.getMainActivityWrapper().onMainActivityCreated(this); if (BuildConfig.ENG && SystemProperties.ALLOW_STRICT_MODE.getValue()) { Toast.makeText(this, "Using Strict Mode for eng builds", Toast.LENGTH_SHORT).show(); } mTracker = tvApplication.getTracker(); mTvInputManagerHelper = tvApplication.getTvInputManagerHelper(); mTvInputManagerHelper.addCallback(mTvInputCallback); mUsbTunerInputId = UsbTunerTvInputService.getInputId(this); mChannelDataManager = tvApplication.getChannelDataManager(); mProgramDataManager = tvApplication.getProgramDataManager(); mProgramDataManager.addOnCurrentProgramUpdatedListener(Channel.INVALID_ID, mOnCurrentProgramUpdatedListener); mProgramDataManager.setPrefetchEnabled(true); mChannelTuner = new ChannelTuner(mChannelDataManager, mTvInputManagerHelper); mChannelTuner.addListener(mChannelTunerListener); mChannelTuner.start(); mPipInputManager = new PipInputManager(this, mTvInputManagerHelper, mChannelTuner); mPipInputManager.start(); mMemoryManageables.add(mProgramDataManager); mMemoryManageables.add(ImageCache.getInstance()); mMemoryManageables.add(TvContentRatingCache.getInstance()); if (CommonFeatures.DVR.isEnabled(this) && BuildCompat.isAtLeastN()) { mDvrManager = tvApplication.getDvrManager(); mDvrDataManager = tvApplication.getDvrDataManager(); } DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY); Point size = new Point(); display.getSize(size); int screenWidth = size.x; int screenHeight = size.y; mDefaultRefreshRate = display.getRefreshRate(); mOverlayRootView = (OverlayRootView) getLayoutInflater().inflate(R.layout.overlay_root_view, null, false); setContentView(R.layout.activity_tv); mTvView = (TunableTvView) findViewById(R.id.main_tunable_tv_view); int shrunkenTvViewHeight = getResources().getDimensionPixelSize(R.dimen.shrunken_tvview_height); mTvView.initialize((AppLayerTvView) findViewById(R.id.main_tv_view), false, screenHeight, shrunkenTvViewHeight); mTvView.setOnUnhandledInputEventListener(new OnUnhandledInputEventListener() { @Override public boolean onUnhandledInputEvent(InputEvent event) { if (isKeyEventBlocked()) { return true; } if (event instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.isLongPress()) { if (onKeyLongPress(keyEvent.getKeyCode(), keyEvent)) { return true; } } if (keyEvent.getAction() == KeyEvent.ACTION_UP) { return onKeyUp(keyEvent.getKeyCode(), keyEvent); } else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { return onKeyDown(keyEvent.getKeyCode(), keyEvent); } } return false; } }); mTimeShiftManager = new TimeShiftManager(this, mTvView, mProgramDataManager, mTracker, new OnCurrentProgramUpdatedListener() { @Override public void onCurrentProgramUpdated(long channelId, Program program) { updateMediaSession(); switch (mTimeShiftManager.getLastActionId()) { case TimeShiftManager.TIME_SHIFT_ACTION_ID_REWIND: case TimeShiftManager.TIME_SHIFT_ACTION_ID_FAST_FORWARD: case TimeShiftManager.TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS: case TimeShiftManager.TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT: updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_FORCE_SHOW); break; default: updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_UPDATE_INFO); break; } } }); mPipView = (TunableTvView) findViewById(R.id.pip_tunable_tv_view); mPipView.initialize((AppLayerTvView) findViewById(R.id.pip_tv_view), true, screenHeight, shrunkenTvViewHeight); if (!PermissionUtils.hasAccessWatchedHistory(this)) { WatchedHistoryManager watchedHistoryManager = new WatchedHistoryManager(getApplicationContext()); watchedHistoryManager.start(); mTvView.setWatchedHistoryManager(watchedHistoryManager); } mTvViewUiManager = new TvViewUiManager(this, mTvView, mPipView, (FrameLayout) findViewById(android.R.id.content), mTvOptionsManager); mPipView.setFixedSurfaceSize(screenWidth / 2, screenHeight / 2); mPipView.setBlockScreenType(TunableTvView.BLOCK_SCREEN_TYPE_SHRUNKEN_TV_VIEW); ViewGroup sceneContainer = (ViewGroup) findViewById(R.id.scene_container); mChannelBannerView = (ChannelBannerView) getLayoutInflater().inflate(R.layout.channel_banner, sceneContainer, false); mKeypadChannelSwitchView = (KeypadChannelSwitchView) getLayoutInflater() .inflate(R.layout.keypad_channel_switch, sceneContainer, false); InputBannerView inputBannerView = (InputBannerView) getLayoutInflater().inflate(R.layout.input_banner, sceneContainer, false); SelectInputView selectInputView = (SelectInputView) getLayoutInflater().inflate(R.layout.select_input, sceneContainer, false); selectInputView.setOnInputSelectedCallback(new OnInputSelectedCallback() { @Override public void onTunerInputSelected() { Channel currentChannel = mChannelTuner.getCurrentChannel(); if (currentChannel != null && !currentChannel.isPassthrough()) { hideOverlays(); } else { tuneToLastWatchedChannelForTunerInput(); } } @Override public void onPassthroughInputSelected(TvInputInfo input) { Channel currentChannel = mChannelTuner.getCurrentChannel(); String currentInputId = currentChannel == null ? null : currentChannel.getInputId(); if (TextUtils.equals(input.getId(), currentInputId)) { hideOverlays(); } else { tuneToChannel(Channel.createPassthroughChannel(input.getId())); } } private void hideOverlays() { getOverlayManager().hideOverlays(TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_PROGRAM_GUIDE | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_MENU | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT); } }); mSearchFragment = new ProgramGuideSearchFragment(); mOverlayManager = new TvOverlayManager(this, mChannelTuner, mKeypadChannelSwitchView, mChannelBannerView, inputBannerView, selectInputView, sceneContainer, mSearchFragment); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mAudioFocusStatus = AudioManager.AUDIOFOCUS_LOSS; mMediaSession = new MediaSession(this, MEDIA_SESSION_TAG); mMediaSession.setCallback(new MediaSession.Callback() { @Override public boolean onMediaButtonEvent(Intent mediaButtonIntent) { // Consume the media button event here. Should not send it to other apps. return true; } }); mMediaSession .setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); mNowPlayingCardWidth = getResources().getDimensionPixelSize(R.dimen.notif_card_img_max_width); mNowPlayingCardHeight = getResources().getDimensionPixelSize(R.dimen.notif_card_img_height); mTvViewUiManager.restoreDisplayMode(false); if (!handleIntent(getIntent())) { finish(); return; } mAudioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, new AudioCapabilitiesReceiver.OnAc3PassthroughCapabilityChangeListener() { @Override public void onAc3PassthroughCapabilityChange(boolean capability) { mAc3PassthroughSupported = capability; } }); mAudioCapabilitiesReceiver.register(); mAccessibilityManager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE); mSendConfigInfoRecurringRunner = new RecurringRunner(this, TimeUnit.DAYS.toMillis(1), new SendConfigInfoRunnable(mTracker, mTvInputManagerHelper), null); mSendConfigInfoRecurringRunner.start(); mChannelStatusRecurringRunner = SendChannelStatusRunnable.startChannelStatusRecurringRunner(this, mTracker, mChannelDataManager); // To avoid not updating Rating systems when changing language. mTvInputManagerHelper.getContentRatingsManager().update(); initForTest(); }
From source file:com.farmerbb.taskbar.service.StartMenuService.java
@SuppressWarnings("deprecation") private void openContextMenu(final int[] location) { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); new Handler().postDelayed(() -> { SharedPreferences pref = U.getSharedPreferences(StartMenuService.this); Intent intent = null;//from www.j av a 2 s . c om switch (pref.getString("theme", "light")) { case "light": intent = new Intent(StartMenuService.this, ContextMenuActivity.class); break; case "dark": intent = new Intent(StartMenuService.this, ContextMenuActivityDark.class); break; } if (intent != null) { intent.putExtra("launched_from_start_menu", true); intent.putExtra("is_overflow_menu", true); intent.putExtra("x", location[0]); intent.putExtra("y", location[1]); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && FreeformHackHelper.getInstance().isInFreeformWorkspace()) { DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); if (intent != null && U.isOPreview()) intent.putExtra("context_menu_fix", true); startActivity(intent, U.getActivityOptions(ApplicationType.CONTEXT_MENU) .setLaunchBounds(new Rect(0, 0, display.getWidth(), display.getHeight())).toBundle()); } else startActivity(intent); }, shouldDelay() ? 100 : 0); }
From source file:com.farmerbb.taskbar.service.TaskbarService.java
@SuppressWarnings("deprecation") private void openContextMenu() { SharedPreferences pref = U.getSharedPreferences(this); Intent intent = null;//from w ww .ja v a 2 s . c o m switch (pref.getString("theme", "light")) { case "light": intent = new Intent(this, ContextMenuActivity.class); break; case "dark": intent = new Intent(this, ContextMenuActivityDark.class); break; } if (intent != null) { intent.putExtra("dont_show_quit", LauncherHelper.getInstance().isOnHomeScreen() && !pref.getBoolean("taskbar_active", false)); intent.putExtra("is_start_button", true); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && FreeformHackHelper.getInstance().isInFreeformWorkspace()) { DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); if (intent != null && U.isOPreview()) intent.putExtra("context_menu_fix", true); startActivity(intent, U.getActivityOptions(ApplicationType.CONTEXT_MENU) .setLaunchBounds(new Rect(0, 0, display.getWidth(), display.getHeight())).toBundle()); } else startActivity(intent); }
From source file:com.farmerbb.taskbar.service.TaskbarService.java
@SuppressWarnings("deprecation") private void openContextMenu(AppEntry entry, int[] location) { SharedPreferences pref = U.getSharedPreferences(this); Intent intent = null;//from www . j a v a 2 s . c o m switch (pref.getString("theme", "light")) { case "light": intent = new Intent(this, ContextMenuActivity.class); break; case "dark": intent = new Intent(this, ContextMenuActivityDark.class); break; } if (intent != null) { intent.putExtra("package_name", entry.getPackageName()); intent.putExtra("app_name", entry.getLabel()); intent.putExtra("component_name", entry.getComponentName()); intent.putExtra("user_id", entry.getUserId(this)); intent.putExtra("x", location[0]); intent.putExtra("y", location[1]); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && FreeformHackHelper.getInstance().isInFreeformWorkspace()) { DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); if (intent != null && U.isOPreview()) intent.putExtra("context_menu_fix", true); startActivity(intent, U.getActivityOptions(ApplicationType.CONTEXT_MENU) .setLaunchBounds(new Rect(0, 0, display.getWidth(), display.getHeight())).toBundle()); } else startActivity(intent); }
From source file:com.android.tv.MainActivity.java
private void applyDisplayRefreshRate(float videoFrameRate) { boolean is24Fps = Math.abs(videoFrameRate - FRAME_RATE_FOR_FILM) < FRAME_RATE_EPSILON; if (mIsFilmModeSet && !is24Fps) { setPreferredRefreshRate(mDefaultRefreshRate); mIsFilmModeSet = false;/*from w ww . ja v a 2 s.com*/ } else if (!mIsFilmModeSet && is24Fps) { DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY); float[] refreshRates = display.getSupportedRefreshRates(); for (float refreshRate : refreshRates) { // Be conservative and set only when the display refresh rate supports 24fps. if (Math.abs(videoFrameRate - refreshRate) < REFRESH_RATE_EPSILON) { setPreferredRefreshRate(refreshRate); mIsFilmModeSet = true; return; } } } }