Skip to content

Instantly share code, notes, and snippets.

@bapspatil
Created October 9, 2018 06:04
Show Gist options
  • Save bapspatil/ca47df4c0ea97050df157673919035c0 to your computer and use it in GitHub Desktop.
Save bapspatil/ca47df4c0ea97050df157673919035c0 to your computer and use it in GitHub Desktop.
MySliceProvider: Creating a SliceAction
private fun createActivityAction(): SliceAction? {
// (1) Create a SliceAction as follows.
return SliceAction.create(
/* (2)
** Pass in a PendingIntent,
** icon to display on the slice,
** size of the icon, and
** and the title of the action,
** to handle the on-click action for a Slice.
*/
PendingIntent.getActivity(
context, 0, Intent(context, MainActivity::class.java), 0
),
IconCompat.createWithResource(context, R.drawable.ic_launcher_foreground),
ListBuilder.ICON_IMAGE,
"Open App"
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment