btn_snapshot.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TakeScreenshot(); Picture picture = webview.capturePicture(); Bitmap b = Bitmap.createBitmap( picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas( b ); picture.draw( c ); // FileOutputStream fos = null; try { File wallpaperDirectory = new File("/sdcard/HAS Snaps/"); wallpaperDirectory.mkdirs(); currentDateTimeString=java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()); File outputFile = new File(wallpaperDirectory, currentDateTimeString+".jpg"); FileOutputStream fos = new FileOutputStream(outputFile); if ( fos != null ) { b.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.close(); // sav_image(); Show_Custom_Toast("Image saved", R.drawable.success); sendBroadcast(new Intent(Intent.ACTION_MEDIA_SHARED, Uri.parse("content://"+Environment.getStorageState(outputFile)))); } else { Show_Custom_Toast("Error in saving image", R.drawable.invalid); } } catch( Exception e ) { } } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)