Skip to content

Instantly share code, notes, and snippets.

@kartikarora
Last active May 1, 2023 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikarora/b2040ff8b18dd4f15b44793a043780b4 to your computer and use it in GitHub Desktop.
Save kartikarora/b2040ff8b18dd4f15b44793a043780b4 to your computer and use it in GitHub Desktop.
val customActionOne = ChooserAction.Builder(
Icon.createWithResource(applicationContext, R.drawable.outline_android),
getString(R.string.app_name),
PendingIntent.getActivity(
applicationContext,
/* Request code for the pending intent */ REQUEST_CODE,
/* Intent for the custom action */ intent,
PendingIntent.FLAG_IMMUTABLE
)
).build()
val customActionTwo = ChooserAction.Builder(
Icon.createWithResource(applicationContext, R.drawable.baseline_android),
getString(R.string.app_name),
PendingIntent.getActivity(
applicationContext,
/* Request code for the pending intent */ REQUEST_CODE,
/* Intent for the custom action */ intent,
PendingIntent.FLAG_IMMUTABLE
)
).build()
val chooserIntent = Intent.createChooser(
// your share intent goes here
).apply {
putExtra(Intent.EXTRA_CHOOSER_CUSTOM_ACTIONS, arrayOf(customActionOne, customActionTwo))
}
startActivity(chooserIntent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment