How to add a button directly to Notification on Android Wear

On the Google I / O Bytes video ad How we set up Google Apps for Android Wear ( https://www.google.ca/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCAQtwIwAA&url=http% 3A% 2F% 2Fwww.youtube.com% 2Fwatch% 3Fv% 3Do5cne6vK-eo & ei = gYyxU4v8EcWu8AGl0oCgDA & usg = AFQjCNEUFIJHz7EK-SQue73mMar0ekir6Q & bvm = webut , I see the Camera button, I’ve clicked on the Camera button to activate the camera’s (and not at the end of the notification as a new page, which will happen if addAction or setContentAction is used).

Does anyone know which API I need to use for this? I don’t think that user activity is used for the first view, because it looks like the first screen of Android Wear when there is at least one notification. I tried to find it in the documents, but could not get it. I tried setDisplayIntent, which is suggested by others, but it does not seem to be the same.

+4
source share
2 answers

WearableExtender.setContentAction(int), . int , ( NotificationCompat.Builder.addAction(NotificationCompat.Action)). . , .

, SDK, ( /​​samples/android-20/wearable/Notifications), , . , , :

NotificationCompat.Action action = new NotificationCompat.Action.Builder(
        R.drawable.ic_result_open, null, NotificationUtil.getExamplePendingIntent(
        context, R.string.example_content_action_clicked)).build();

NotificationCompat.Builder builder =
    new NotificationCompat.Builder(context)
        .setSmallIcon(R.mipmap.ic_launcher)
        .setContentTitle("Title")
        .setContentText("Context Text")
        .addAction(action)
    .extend(new NotificationCompat.WearableExtender()
        .setContentAction(0));
+4

, , ( , ) - API Wearable Data Layer. () , , . ( Data Layer API) , .

0

Source: https://habr.com/ru/post/1546588/


All Articles