Hi all,
Can anybody tell me wats d code for capturing the screen of android mobiles, while we run an application. I need the code for capturing both the application screen and the background screen.


private void captureScreen() {
RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main);
File root = Environment.getExternalStorageDirectory();
File file = new File(root,"androidlife.jpg");
Bitmap b = Bitmap.createBitmap(mainLayout.getWidth(), mainLayout
.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
mainLayout.draw(c);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
if (fos != null) {
b.compress(Bitmap.CompressFormat.JPEG, 90, fos);
fos.close();
}
} catch (Exception e) {
e.printStackTrace();



gokberks wrote:
- Code: Select all
private void captureScreen() {
RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main);
File root = Environment.getExternalStorageDirectory();
File file = new File(root,"androidlife.jpg");
Bitmap b = Bitmap.createBitmap(mainLayout.getWidth(), mainLayout
.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
mainLayout.draw(c);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
if (fos != null) {
b.compress(Bitmap.CompressFormat.JPEG, 90, fos);
fos.close();
}
} catch (Exception e) {
e.printStackTrace();
can you try this code?
this code create androidlife.jpg on your sdcard folder



V!j! Neelu wrote:Thanks for the reply. But i need it without SD card. And in specific i need how to capture for the key events.


Users browsing this forum: No registered users and 4 guests