Skip to content

Instantly share code, notes, and snippets.

@shiveshmehta09
Last active January 26, 2019 07:15
Show Gist options
  • Save shiveshmehta09/619e300f3ded2a09df0f68c77e8e8da6 to your computer and use it in GitHub Desktop.
Save shiveshmehta09/619e300f3ded2a09df0f68c77e8e8da6 to your computer and use it in GitHub Desktop.
/* 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