Reputation: 112
I need to show more data than slices could show, so i used the method setSeeMoreAction(PendingIntent intent), which adds a "see more" affordance at the end of slice and we can set which action to invoke when tapping it with the help of PendingIntent.
While testing my slices on slice-viewer app, i can see the "show more" affordance and clicking on which works as expected, but when i test it using "App Actions Test Tool", it doesn't show this "see more" affordance. Instead sometimes (while sometimes nothing is shown) it shows an "Open App" button clicking on which don't trigger the pending intent which i have mentioned in setSeeMoreAction, it instead triggers the SliceAction mentioned in setPrimaryAction() of RowBuilder.
Here is my Code :
override fun onBindSlice(sliceUri: Uri): Slice? {
if(!isLoggedIn()) // if user is not logged in
{
return createLoginSlice(sliceUri).build()
}
var head = ListBuilder.HeaderBuilder()
.setTitle("Slice Title")
var slice = ListBuilder(context,sliceUri,ListBuilder.INFINITY)
.setSeeMoreAction(orderActivityPendingIntent())
.setHeader(head)
for(i in 0 .. 6) {
icon = IconCompat.createWithResource(context.applicationContext, R.drawable.placeholder)
var row = ListBuilder.RowBuilder()
.setTitleItem(icon!!,ListBuilder.LARGE_IMAGE,true)
.setTitle(orderName.get(i),true)
.setSubtitle(orderStatus.get(i),true)
.addEndItem(IconCompat.createWithResource(context, colorScheme.get(i)),ListBuilder.SMALL_IMAGE)
.setPrimaryAction(openOrderActivity(orderId.get(i)))
slice.addRow(row)
}
return slice.build()
}
@RequiresApi(Build.VERSION_CODES.KITKAT)
private fun openOrderActivity(orderNo: String?): SliceAction {
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse(context.getString(R.string.orderURI)+orderNo))
return SliceAction.create(
PendingIntent.getActivity(context, 0, intent, 0),
IconCompat.createWithResource(context, R.drawable.abc_ic_star_black_36dp),
ListBuilder.ICON_IMAGE,
"Open Order Activity."
)
}
private fun orderActivityPendingIntent(): PendingIntent {
// create intent for order page here
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.orderPageURI)))
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
Upvotes: 1
Views: 255
Reputation: 21399
As per the docs (although easy to miss):
If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off.
(key being "may").
Basically it's up to the app displaying the Slice (in this case Google Assistant) as to if it displays the "see more" affordance. In the case of Assistant, it may not be showing it because it automatically appends a "Open App" button to every Slice it displays so you should use that to link the user to see more info or take further action.
If you think "see more" would be useful in your case, you can file a feature request for App Actions + Slices to support his along with details of your use-cas.
Upvotes: 0