1

アプリケーション内から Blackberry デバイスのホーム画面(メイン ディスプレイ画面) のスクリーンショットを取得するにはどうすればよいですか(アプリケーションの背景画像として使用するため)。使用したことがありますが、アプリケーションの現在の画面のスクリーンショットが必要で、デバイスのホーム画面のスクリーンショットが必要です。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) {
                }
            }
        }
    }
}
4

0 に答える 0