如何从我的应用程序中截取黑莓设备的主屏幕(主显示屏)屏幕截图(将其用作我的应用程序中的背景图像)?我用过,但它需要我的应用程序当前屏幕的屏幕截图,我需要我设备主屏幕的屏幕截图。Display.screenshot(bm)
private class CaptureThread extends Thread {
public CaptureThread() {
}
public void run() {
FileConnection fc = null;
DataOutputStream out = null;
try {
// MainScreen objMainScreen=new MainScreen();
int width = Display.getWidth();
// int width=objMainScreen.getWidth();
int height = Display.getHeight();
Bitmap bm = new Bitmap(width, height);
Display.screenshot(bm);
PNGEncodedImage png = PNGEncodedImage.encode(bm);
// Save the PNG to the micro SD card.
fc = (FileConnection) Connector
.open("file:///SDCard/BlackBerry/pictures/screenCap.png");
if (fc.exists()) {
fc.delete();
}
fc.create();
out = fc.openDataOutputStream();
out.write(png.getData());
} catch (Exception ex) {
System.out.println("Exception: " + ex.toString());
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
}
}
if (fc != null) {
try {
fc.close();
} catch (IOException e) {
}
}
}
}
}