Code example for Bitmap

Methods: compressrecycle

			String name = message.getData().getString("name");
			int quality = message.arg1;
			Bitmap b = (Bitmap)message.obj;
			if(b != null) {
				saveFile(name, b, quality);
			else { 
				Log.d(LOG_TAG, "NULL BITMAP!!");
		 * Saves a file. 
		 * @param name the name of the file 
		 * @param b the bitmap to save 
		 * @param quality the compression rate. From 0 (compress for lowest size) to 100 (compress for maximum quality). 
		private void saveFile(String name, Bitmap b, int quality){
			FileOutputStream fos = null;
			String fileName = getFileName(name);
			File directory = new File(Environment.getExternalStorageDirectory() + "/Robotium-Screenshots/");
			File fileToSave = new File(directory,fileName);
			try { 
				fos = new FileOutputStream(fileToSave);
				if (b.compress(Bitmap.CompressFormat.JPEG, quality, fos) == false)
					Log.d(LOG_TAG, "Compress/Write failed");
			} catch (Exception e) {
				Log.d(LOG_TAG, "Can't save the screenshot! Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under test.");
Stop searching for code, let great code find you!  Add Codota to your java IDE