Skip to content

Instantly share code, notes, and snippets.

@ElianFabian
Created November 9, 2024 18:50
Show Gist options
  • Select an option

  • Save ElianFabian/58720faa70ad20f3222ee0fec0d60af1 to your computer and use it in GitHub Desktop.

Select an option

Save ElianFabian/58720faa70ad20f3222ee0fec0d60af1 to your computer and use it in GitHub Desktop.
Android extensions
import android.content.Intent
import android.os.Bundle
@Suppress("DEPRECATION")
fun Bundle.contentToString(): String {
return "Bundle(${
keySet().joinToString { key ->
when (val value = get(key)) {
is Bundle -> "$key=${value.contentToString()}"
is Array<*> -> "$key=${value.contentToString()}"
is IntArray -> "$key=${value.contentToString()}"
is LongArray -> "$key=${value.contentToString()}"
is FloatArray -> "$key=${value.contentToString()}"
is DoubleArray -> "$key=${value.contentToString()}"
is BooleanArray -> "$key=${value.contentToString()}"
is CharArray -> "$key=${value.contentToString()}"
else -> "$key=$value"
}
}
})"
}
fun Intent.contentToString(): String {
return "Intent(action=$action, data=$data, type=$type, component=$component, categories=$categories, flags=$flags, selector=${selector?.contentToString()}, extras=${extras?.contentToString()})"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment