Last active
January 26, 2019 07:15
-
-
Save shiveshmehta09/619e300f3ded2a09df0f68c77e8e8da6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Store taken screenshot into above created path */ | |
fun storeScreenShot(bm: Bitmap?, fileName: String, context: Context?): File { | |
val dir = File(context?.filesDir?.absolutePath) | |
if (!dir.exists()) | |
dir.mkdirs() | |
val file = File(context?.filesDir?.absolutePath, fileName) | |
Timber.d("Create Directory Created : $file") | |
try { | |
val fOut = FileOutputStream(file) | |
bm?.compress(Bitmap.CompressFormat.JPEG, 10, fOut) | |
fOut.flush() | |
fOut.close() | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} | |
return file | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment