當前位置: 首頁>>代碼示例>>Java>>正文


Java DisplayManager類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:dsaved,項目名稱:africhat-platform-0.1,代碼行數:17,代碼來源:AndroidMessenger.java

示例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();
}
 
開發者ID:IOT-DSA,項目名稱:dslink-java-android,代碼行數:25,代碼來源:ScreenProvider.java

示例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);
        }
    }
}
 
開發者ID:kaixuanluo,項目名稱:pc-android-controller-android,代碼行數:29,代碼來源:ScreenCaptureService.java

示例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);
        }
    }
}
 
開發者ID:kaixuanluo,項目名稱:pc-android-controller-android,代碼行數:29,代碼來源:ScreenCaptureSocket.java

示例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();
    }
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:22,代碼來源:ScreenRecorder.java

示例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);
}
 
開發者ID:itsnothingg,項目名稱:EasyScreenRecorder,代碼行數:23,代碼來源:MediaScreenEncoder.java

示例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);
}
 
開發者ID:sunshinecoast,項目名稱:ScreenRecordCaptureMaster,代碼行數:25,代碼來源:CaptureScreenImage.java

示例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);
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:26,代碼來源:DvrPlaybackOverlayFragment.java

示例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;
            }
        }
    }
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:22,代碼來源:MainActivity.java

示例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
    );
}
 
開發者ID:ankyl,項目名稱:castscreen,代碼行數:19,代碼來源:ProjectionManager.java

示例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();
        }
    }
}
 
開發者ID:MotorolaMobilityLLC,項目名稱:mdkdisplay,代碼行數:27,代碼來源:MainActivity.java

示例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());
        }
    }
 
開發者ID:punchup,項目名稱:Superuser-UI,代碼行數:18,代碼來源:SuReceiver.java

示例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();
    }
}
 
開發者ID:legendmohe,項目名稱:LEHomeMobile_android,代碼行數:17,代碼來源:ComUtil.java

示例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();
}
 
開發者ID:omerjerk,項目名稱:RemoteDroid,代碼行數:27,代碼來源:ServerService.java

示例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 */ }
}
 
開發者ID:farmerbb,項目名稱:SecondScreen,代碼行數:17,代碼來源:NotificationService.java


注:本文中的android.hardware.display.DisplayManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。