Back in
Google I/O 2015, we saw the Now on Tap feature, where Google Now could peek into a running app and provide contextual assistance. The Assist
API offers a new way for users to engage through an
assistant. The assistant must be enabled prior to using it, allowing it to be aware of the current context. Triggering the assistant is done by long-pressing the Home button, no matter which app is active.
You can opt out of this by setting the WindowManager.LayoutParams.FLAG_SECURE
flag.
Opting in requires you to use the new AssistContent
class.
In order for us to be able to feed additional context from our app to the assistant, we need to follow these steps:
Implement the
Application.OnProvideAssistDataListener
interface, which is called when the user requests assistance.Register it using
Application.registerOnProvideAssistDataListener()
.Override the
onProvideAssistData()
callback, which is called when the user requests assistance. It is used to build anACTION_ASSIST
intent...