i have first build a facebook chat head widget and need to take the screenshots of applications and programs opened other than my program i am using for screenshot
the code i am using for saving screenshot is
public static Bitmap getScreenShot(View view) {
View screenView = view.getRootView();
screenView.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
screenView.setDrawingCacheEnabled(false);
return bitmap;
}
and the button when clicked exectues this code
if (Xdiff < 10 && Ydiff < 10) {
if (isViewCollapsed()) {
//When user clicks on the image view of the collapsed layout,
//visibility of the collapsed layout will be changed to "View.GONE"
//and expanded view will become visible.
Bitmap b = null;
b = Screenshot.getScreenShot(v);
if (b != null)
{
File saveFile = com.ocr.ocr.Screenshot.getMainDirectoryName(FloatingViewService.this);//get the path to save screenshot
File file = com.ocr.ocr.Screenshot.store(b, "screenshot" + ".jpg", saveFile);//save the screenshot to selected path
shareScreenshot(file);//finally share screenshot
}else{
Toast.makeText(getApplicationContext(), "Some error occured", Toast.LENGTH_LONG).show();
}
}
}
Thanks a lot Regards