How To Make A Capture Screen App On Android
Solution 1:
Programatically you can do so by executing the below command using adb:
adb shell /system/bin/screencap -p /sdcard/img.png
However to do the same from an application you can use the below method:
Processsh= Runtime.getRuntime().exec("su", null,null); //getting superuser permission to access /system/binOutputStreamos= sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII")); //executing the command
os.flush();
os.close();
sh.waitFor();
In /sdcard/
you will have img.png which will be your screen shot.
Solution 2:
From the FAQ of the app:
No “Capture Method” available for my device!
This is normal if your device isn't rooted. It's the way how the Android security model works; it just doesn't allow taking a screenshot on some devices. However, you can enable screenshot functionality on your device by enabling it through a computer. To see how you can do this go to “Screenshot Ultimate” > “Settings” > “Capture methods” > “No capture method help”. You can email the manual to yourself so you can complete it on your computer (Windows, Linux or Mac OSX).
Solution 3:
Check if this can help you out. The following code will help you to capture the screen of a particular Layout
RelativeLayout screenShotLayout=(RelativeLayout)findViewById(R.id.ScreenShotLayout);
Bitmap Bitmapimage=Bitmap.createBitmap(screenShotLayout.getWidth(),screenShotLayout.getHeight(), Config.ARGB_8888);
screenShotLayout.setDrawingCacheEnabled(true);
screenShotLayout.buildDrawingCache();
Bitmapimage=screenShotLayout.getDrawingCache();
//Bitmapimage is the screenshot of the layout. Do your stuff with it
Solution 4:
// image naming and path to include sd card appending name you choose for fileStringmPath= Environment.getExternalStorageDirectory().toString() + "/" + ACCUWX.IMAGE_APPEND;
// create bitmap screen capture
Bitmap bitmap;
Viewv1= mCurrentUrlMask.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
OutputStreamfout=null;
imageFile = newFile(mPath);
try {
fout = newFileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);
fout.flush();
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
To access the files :
Uriuri= Uri.fromFile(newFile(mPath));
Post a Comment for "How To Make A Capture Screen App On Android"