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


Java DisplayManager.getDisplays方法代碼示例

本文整理匯總了Java中android.hardware.display.DisplayManager.getDisplays方法的典型用法代碼示例。如果您正苦於以下問題:Java DisplayManager.getDisplays方法的具體用法?Java DisplayManager.getDisplays怎麽用?Java DisplayManager.getDisplays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.hardware.display.DisplayManager的用法示例。


在下文中一共展示了DisplayManager.getDisplays方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: castScreenActive

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
public static boolean castScreenActive(Context context) {
    DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    Display[] displays = dm.getDisplays();

    for(Display display : displays) {
        try {
            if(Class.forName("android.view.Display")
                    .getMethod("getOwnerPackageName")
                    .invoke(display)
                    .equals("com.google.android.gms"))
                return true;
        } catch (Exception e) { /* Gracefully fail */ }
    }

    return false;
}
 
開發者ID:farmerbb,項目名稱:SecondScreen,代碼行數:17,代碼來源:U.java

示例7: IsScreenOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
public boolean IsScreenOn() {
    DisplayManager displayManager = (DisplayManager) _context.getSystemService(Context.DISPLAY_SERVICE);
    if (displayManager == null) {
        Logger.getInstance().Error(TAG, "displayManager is null!");
        return false;
    }

    for (Display display : displayManager.getDisplays()) {
        if (display.getState() != Display.STATE_OFF) {
            return true;
        }
    }
    return false;
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:15,代碼來源:DisplayController.java

示例8: isScreenOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
public static boolean isScreenOn(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        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(Context.POWER_SERVICE);
        return powerManager.isScreenOn();
    }
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:15,代碼來源:Utils.java

示例9: isScreenOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
public static boolean isScreenOn(Context context)
{
	DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
	for (Display display : dm.getDisplays())
	{
		if (display.getState() != Display.STATE_OFF)
			return true;
	}
	return false;
}
 
開發者ID:ryanchyshyn,項目名稱:aosp_screen_stabilization,代碼行數:11,代碼來源:Utils.java

示例10: isScreenOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
public static boolean isScreenOn(Context context) {
    DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    for (Display display : dm.getDisplays()) {
        if (display.getState() == Display.STATE_ON
                || display.getState() == Display.STATE_UNKNOWN) {
            return true;
        }
    }
    return false;
}
 
開發者ID:theblixguy,項目名稱:ForceDoze,代碼行數:11,代碼來源:Utils.java

示例11: IsScreenOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
public boolean IsScreenOn() {
    DisplayManager displayManager = (DisplayManager) _context.getSystemService(Context.DISPLAY_SERVICE);
    for (Display display : displayManager.getDisplays()) {
        if (display.getState() != Display.STATE_OFF) {
            return true;
        }
    }
    return false;
}
 
開發者ID:GuepardoApps,項目名稱:library_GuepardoAppsToolSet,代碼行數:10,代碼來源:DisplayController.java

示例12: isScreenOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
boolean isScreenOn() {
    if (Utils.isAndroidNewerThanL()) {
        DisplayManager dm = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                return true;
            }
        }
        return false;
    } else {
        PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
        return powerManager.isScreenOn();
    }
}
 
開發者ID:rosenpin,項目名稱:AlwaysOnDisplayAmoled,代碼行數:15,代碼來源:StarterService.java

示例13: isDisplayOn

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
private boolean isDisplayOn(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        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(Context.POWER_SERVICE);
        return powerManager.isScreenOn();
    }
}
 
開發者ID:rosenpin,項目名稱:AlwaysOnDisplayAmoled,代碼行數:15,代碼來源:ChargeChangeReceiver.java

示例14: onClock

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
/** Show a clock on remote presentation view */
private void onClock() {
    DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
    Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
    if (presentationDisplays.length > 0) {
        /**
         * If there is more than one suitable presentation display, then we could consider
         * giving the user a choice.  For this example, we simply choose the first display
         * which is the one the system recommends as the preferred presentation display.
         */
        Display display = presentationDisplays[0];

        try {
            /** Clean up previously presentation view */
            if (presentation != null) {
                presentation.dismiss();
                presentation = null;
            }
            presentation = new ClockActivity(this, display);
            presentation.show();
            Toast.makeText(this, getString(R.string.presentation_mode), Toast.LENGTH_SHORT).show();
        } catch (WindowManager.InvalidDisplayException e) {
            e.printStackTrace();
        }
    } 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,代碼行數:32,代碼來源:MainActivity.java

示例15: onPresentation

import android.hardware.display.DisplayManager; //導入方法依賴的package包/類
/** Show a picture on remote presentation view */
private void onPresentation(Uri image) {
    DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
    Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
    if (presentationDisplays.length > 0) {
        /**
         * If there is more than one suitable presentation display, then we could consider
         * giving the user a choice.  For this example, we simply choose the first display
         * which is the one the system recommends as the preferred presentation display.
         */
        Display display = presentationDisplays[0];
        try {
            /** Clean up previously presentation view */
            if (presentation != null) {
                presentation.dismiss();
                presentation = null;
            }
            presentation = new PresentationActivity(this, display, image);
            presentation.show();

            Toast.makeText(this, getString(R.string.presentation_mode), Toast.LENGTH_SHORT).show();
        } catch (WindowManager.InvalidDisplayException e) {
            e.printStackTrace();
        }
    } 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,代碼行數:32,代碼來源:MainActivity.java


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