Skip to content

Instantly share code, notes, and snippets.

@sanogueralorenzo
Last active December 12, 2018 18:03
Show Gist options
  • Save sanogueralorenzo/d6292b309a29c571e400f7cb22a94a1e to your computer and use it in GitHub Desktop.
Save sanogueralorenzo/d6292b309a29c571e400f7cb22a94a1e to your computer and use it in GitHub Desktop.
private const val PACKAGE_NAME = "com.sanogueralorenzo.namingishard"
private fun intentTo(className: String): Intent =
Intent(Intent.ACTION_VIEW).setClassName(PACKAGE_NAME, className)
internal fun loadIntentOrNull(className: String): Intent? =
try {
Class.forName(className).run { intentTo(className) }
} catch (e: ClassNotFoundException) {
null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment