当前位置: 首页>>代码示例>>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;未经允许,请勿转载。