Last active
May 1, 2023 23:31
-
-
Save kartikarora/b2040ff8b18dd4f15b44793a043780b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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