Receiving voice input within a notification
In this section, we will be taking a look at how we can use notifications that can allow the user to respond to these by simply using their voice. Since Android wearable devices don't contain a keyboard, a user can swipe on a notification and respond to the action using their voice, or simply by choosing from a list of options presented to them, and tapping on the item right from their Android wearable device.
To receive voice input within a notification, perform the following steps:
- Open the
MainActivity.java
file from within the Project Navigator window. - Modify the
onCreate(Bundle savedInstanceState)
method and add the following highlighted code:@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Clear all previous notifications and // generate new unique ids NotificationManagerCompat.from(this).cancelAll(...