これはセキュリティ違反です。それを行うには、ルート化されたデバイスが必要です。
このコードを独自のアプリで使用できます: (別の質問に対するこの回答からこのコードを取得しました: https://stackoverflow.com/a/5651242/237838 )
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + ACCUWX.IMAGE_APPEND;
// create bitmap screen capture
Bitmap bitmap;
View v1 = mCurrentUrlMask.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
OutputStream fout = null;
imageFile = new File(mPath);
try {
fout = new FileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);
fout.flush();
fout.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
追加のヘルプについては、次のコードを参照してください。
PS DDMS を使用して Android からスクリーンショットを取得することは可能ですが、これは別の話です。
PPSランチャーをその下のアクティビティの上に透過的に描画する場合は、ピクセル形式を RGBA (OpenGL でのみ処理) に設定し、それに応じてレンダリングする必要があります。そのために、下にあるアクティビティのスクリーンショットを撮る必要はありません。
ルート化されたデバイス: ルート化されたデバイスで次のコードを使用します。
process = Runtime.getRuntime().exec("su -c cat /dev/graphics/fb0");
InputStream is = process.getInputStream();