本文整理汇总了Java中android.hardware.display.DisplayManager类的典型用法代码示例。如果您正苦于以下问题:Java DisplayManager类的具体用法?Java DisplayManager怎么用?Java DisplayManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisplayManager类属于android.hardware.display包,在下文中一共展示了DisplayManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isScreenOn
import android.hardware.display.DisplayManager; //导入依赖的package包/类
private boolean isScreenOn() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
boolean screenOn = false;
for (Display display : dm.getDisplays()) {
if (display.getState() != Display.STATE_OFF) {
screenOn = true;
}
}
return screenOn;
} else {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
//noinspection deprecation
return pm.isScreenOn();
}
}
示例2: setup
import android.hardware.display.DisplayManager; //导入依赖的package包/类
@Override
public void setup() {
displayManager = (DisplayManager) LinkService.INSTANCE.getSystemService(Context.DISPLAY_SERVICE);
displayListener = new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int i) {
}
@Override
public void onDisplayRemoved(int i) {
}
@Override
public void onDisplayChanged(int i) {
final int state = displayManager.getDisplay(i).getState();
update(new HashMap<String, Object>() {{
put("On", state == Display.STATE_ON);
}});
}
};
displayManager.registerDisplayListener(displayListener, new Handler());
setEnabled();
}
示例3: initVirtualDisplay
import android.hardware.display.DisplayManager; //导入依赖的package包/类
/**
* 将录屏服务的内容显示到Image面板上.
*/
private void initVirtualDisplay() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
DisplayManager mDisplayManager = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE);
if (mDisplayManager == null) {
L.e(" 获取 播放管理器失败 ... ");
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
L.d("当前安卓 版本 " + Build.VERSION.SDK_INT + " 进入到图片展示 ");
mVirtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", mScreenWidth,
mScreenHeight, mScreenDensity,
mImageReader.getSurface(),
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
}
} else {
if (mMediaProjection == null) {
L.e("mMediaProjection is null ...");
return;
} else {
mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
mImageReader.getSurface(), null, null);
}
}
}
示例4: initVirtualDisplay
import android.hardware.display.DisplayManager; //导入依赖的package包/类
/**
* 将录屏服务的内容显示到Image面板上.
*/
private void initVirtualDisplay() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
DisplayManager mDisplayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
if (mDisplayManager == null) {
L.e(" 获取 播放管理器失败 ... ");
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
L.d("当前安卓 版本 " + Build.VERSION.SDK_INT + " 进入到图片展示 ");
mVirtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", mScreenWidth,
mScreenHeight, mScreenDensity,
mImageReader.getSurface(),
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
}
} else {
if (mMediaProjection == null) {
L.e("mMediaProjection is null ...");
return;
} else {
mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
mImageReader.getSurface(), null, null);
}
}
}
示例5: run
import android.hardware.display.DisplayManager; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void run() {
try {
try {
prepareEncoder();
mMuxer = new MediaMuxer(mDstPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
} catch (IOException e) {
throw new RuntimeException(e);
}
mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG + "-display",
mWidth, mHeight, mDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC,
mSurface, null, null);
Log.d(TAG, "created virtual display: " + mVirtualDisplay);
recordVirtualDisplay();
} finally {
release();
}
}
示例6: onStart
import android.hardware.display.DisplayManager; //导入依赖的package包/类
@Override
protected void onStart() {
if (DEBUG) Log.d(TAG,"mScreenCaptureTask#onStart:");
mDrawer = new GLDrawer2D(true);
mTexId = mDrawer.initTex();
mSourceTexture = new SurfaceTexture(mTexId);
mSourceTexture.setDefaultBufferSize(mWidth, mHeight); // これを入れないと映像が取れない
mSourceSurface = new Surface(mSourceTexture);
mSourceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener, mHandler);
mEncoderSurface = getEgl().createFromSurface(mSurface);
if (DEBUG) Log.d(TAG,"setup VirtualDisplay");
intervals = (long)(1000f / fps);
display = mMediaProjection.createVirtualDisplay(
"Capturing Display",
mWidth, mHeight, mDensity,
DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
mSourceSurface, mCallback, mHandler);
if (DEBUG) Log.v(TAG, "screen capture loop:display=" + display);
// 録画タスクを起床
queueEvent(mDrawTask);
}
示例7: initCapture
import android.hardware.display.DisplayManager; //导入依赖的package包/类
public void initCapture(Context context, MediaProjection mediaProjection, final String path, final IRecordShotCallback callback){
int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
int screenHeight = context.getResources().getDisplayMetrics().heightPixels;
// thread for image checking
mCheckThread = new HandlerThread("CheckHandler");
mCheckThread.start();
mCheckHandler = new Handler(mCheckThread.getLooper());
try {
mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 2);
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
imageAvailable(reader, path, callback);
}
}, mCheckHandler);
mSurface = mImageReader.getSurface();
}finally {
}
mVirtualDisplay = mediaProjection.createVirtualDisplay("mediaprojection", screenWidth, screenHeight,
1, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mSurface, null, null);
}
示例8: onCreate
import android.hardware.display.DisplayManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
if (DEBUG) Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
mExtraPaddingNoRelatedRow = getActivity().getResources()
.getDimensionPixelOffset(R.dimen.dvr_playback_fragment_extra_padding_top);
mDvrDataManager = TvApplication.getSingletons(getActivity()).getDvrDataManager();
mContentRatingsManager = TvApplication.getSingletons(getContext())
.getTvInputManagerHelper().getContentRatingsManager();
mProgram = getProgramFromIntent(getActivity().getIntent());
if (mProgram == null) {
Toast.makeText(getActivity(), getString(R.string.dvr_program_not_found),
Toast.LENGTH_SHORT).show();
getActivity().finish();
return;
}
Point size = new Point();
((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE))
.getDisplay(Display.DEFAULT_DISPLAY).getSize(size);
mWindowWidth = size.x;
mWindowHeight = size.y;
mWindowAspectRatio = mAppliedAspectRatio = (float) mWindowWidth / mWindowHeight;
setBackgroundType(PlaybackOverlayFragment.BG_LIGHT);
setFadingEnabled(true);
}
示例9: applyDisplayRefreshRate
import android.hardware.display.DisplayManager; //导入依赖的package包/类
private void applyDisplayRefreshRate(float videoFrameRate) {
boolean is24Fps = Math.abs(videoFrameRate - FRAME_RATE_FOR_FILM) < FRAME_RATE_EPSILON;
if (mIsFilmModeSet && !is24Fps) {
setPreferredRefreshRate(mDefaultRefreshRate);
mIsFilmModeSet = false;
} 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;
}
}
}
}
示例10: drawOnSurfaceView
import android.hardware.display.DisplayManager; //导入依赖的package包/类
/**
* @param view the SurfaceView on which to draw user's screen
*/
public void drawOnSurfaceView(SurfaceView view) {
if (mDisplay != null) mDisplay.release();
Surface surface = view.getHolder().getSurface();
mDisplay = mProjection.createVirtualDisplay(
VIRTUAL_DISPLAY_NAME,
view.getWidth(),
view.getHeight(),
mDensity,
DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY,
surface,
null,
null
);
}
示例11: selectPhoto
import android.hardware.display.DisplayManager; //导入依赖的package包/类
/**
* Select a picture to show on remote presentation view
*/
private void selectPhoto() {
if (checkSelfPermission("android.permission.READ_EXTERNAL_STORAGE")
!= PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{"android.permission.READ_EXTERNAL_STORAGE"},
REQUEST_STORAGE_PERMISSION);
} else {
DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
if (presentationDisplays.length > 0) {
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
i.setType("image/*");
i.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(i,
getString(R.string.select_picture)), SELECT_PHOTO);
} else {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage(getString(R.string.external_display_not_available));
alert.setPositiveButton(android.R.string.ok, null);
alert.show();
}
}
}
示例12: isScreenOn
import android.hardware.display.DisplayManager; //导入依赖的package包/类
private boolean isScreenOn(Context context) {
if (Build.VERSION.SDK_INT >= 20) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
for (Display display : dm.getDisplays()) {
if (display.getState() != Display.STATE_OFF)
return true;
}
return false;
} else {
PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);
return (powerManager.isScreenOn());
}
}
示例13: isScreenOn
import android.hardware.display.DisplayManager; //导入依赖的package包/类
public static boolean isScreenOn(Context context) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
boolean screenOn = false;
for (Display display : dm.getDisplays()) {
if (display.getState() != Display.STATE_OFF) {
screenOn = true;
}
}
return screenOn;
} else {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
//noinspection deprecation
return pm.isScreenOn();
}
}
示例14: startDisplayManager
import android.hardware.display.DisplayManager; //导入依赖的package包/类
@TargetApi(19)
public void startDisplayManager() {
DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
Surface encoderInputSurface = null;
try {
encoderInputSurface = createDisplaySurface();
} catch (IOException e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
virtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", CodecUtils.WIDTH, CodecUtils.HEIGHT, 50,
encoderInputSurface,
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
} else {
if (MainActivity.mMediaProjection != null) {
virtualDisplay = MainActivity.mMediaProjection.createVirtualDisplay("Remote Droid",
CodecUtils.WIDTH, CodecUtils.HEIGHT, 50,
DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
encoderInputSurface, null, null);
} else {
showToast("Something went wrong. Please restart the app.");
}
}
encoder.start();
}
示例15: onDisplayAdded
import android.hardware.display.DisplayManager; //导入依赖的package包/类
@Override
public void onDisplayAdded(int displayId) {
Intent intent = new Intent();
intent.setAction(U.SCREEN_CONNECT);
LocalBroadcastManager.getInstance(NotificationService.this).sendBroadcast(intent);
DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE);
Display[] displays = dm.getDisplays();
try {
if(displays[displays.length - 2].getDisplayId() == Display.DEFAULT_DISPLAY) {
Intent serviceIntent = new Intent(NotificationService.this, ScreenOnService.class);
startService(serviceIntent);
}
} catch (ArrayIndexOutOfBoundsException e) { /* Gracefully fail */ }
}