Skip to content

Instantly share code, notes, and snippets.

@titoaesj
titoaesj / .kt
Last active June 5, 2024 12:34
Android convert int to dp
OBS: O var_number_int é a varável que recebera o valor a ser convertido em DP
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, var_number_int, getResources().getDisplayMetrics())
##KOTLIN
val Int.dp: Int
get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()
val Float.dp: Int
@stepango
stepango / ShareAudio.kt
Created May 6, 2017 09:31
Share audio file using Android Intent
fun shareItem(item: RecordingItem) {
val requestFile = File(item.filePath)
// Use the FileProvider to get a content URI
val fileUri: Uri = FileProvider.getUriForFile(
context,
"${BuildConfig.APPLICATION_ID}.fileprovider",
requestFile
)