There's a new function called setAllowDataType
on RemoteInput.Builder
in API 26. What is this used for? I tried the following:
val remoteInput = RemoteInput.Builder(KEY_TEXT_REPLY)
.setLabel("Image")
.setAllowFreeFormInput(false)
.setChoices(null)
.setAllowDataType("image/*", true)
.setAllowDataType("image/png", true)
.setAllowDataType("image/jpg", true)
.setAllowDataType("image/gif", true)
.build()
Which should set isDataOnly
to true
on the RemoteInput
, but the notification appeared as the following on the phone. Clicking on the Image
button does nothing. What is this for? I can't find any documentation, release notes, or tutorials on this function.
Update
It looks like the data only types are missing from the notification when it is actually posted. Looking through the builder code, when adding Actions
to the notification, it uses level 24 which strips out the data types entirely: https://android.googlesource.com/platform/frameworks/support/+/oreo-release/compat/api26/android/support/v4/app/NotificationCompatApi26.java#108
Original question still stands.
On Android 12 you can now use
.setAllowDataType("image/*", true)
withRemoteInput
to accept image replies through the notification reply feature.There is no button to select an image, but many keyboards offer features to paste stickers or gifs directly into the notification.