Skip to content

Instantly share code, notes, and snippets.

@BeokBeok
Created October 13, 2022 00:40
Show Gist options
  • Save BeokBeok/e7b58fe3b208098e49bdddc422789ed0 to your computer and use it in GitHub Desktop.
Save BeokBeok/e7b58fe3b208098e49bdddc422789ed0 to your computer and use it in GitHub Desktop.
Debugging Android Intents
fun Intent?.toDebugString(): String {
val intent = this ?: return ""
return StringBuilder().apply {
appendLine("--- Intent ---")
appendLine("type: ${intent.type}")
appendLine("package: ${intent.`package`}")
appendLine("scheme: ${intent.scheme}")
appendLine("component: ${intent.component}")
appendLine("flags: ${intent.flags}")
appendLine("categories: ${intent.categories}")
appendLine("selector: ${intent.selector}")
appendLine("action: ${intent.action}")
appendLine("dataString: ${intent.dataString}")
intent.extras?.keySet()?.forEach { key ->
appendLine("* extra: $key=${intent.extras!![key]}")
}
}.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment