通知不会在Android Wear上自动显示

时间:2019-03-25 10:11:01

标签: android android-wear-2.0 android-wear-notification

也许有人可以帮助我解决以下问题:

我想通过按钮单击事件在LG Urbane 2上以全屏显示通知。我没有使用任何模拟器。

此刻,仅显示小的蓝色半圆形,并在3秒钟后消失。用户首先必须单击该圆圈或在底部将其擦掉,然后NOtification显示为全屏。

如何在onClickEvent上将通知全屏显示并保持可见,直到用户单击它或将其擦除为止?

Here you can see the short 'semicircle' pop-up

Notification should apperar like this

这是我的代码:

showNotification.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Uri alarmSound = getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

                Intent displayIntent = new Intent(context, MainActivity.class);

                PendingIntent displayPendingIntent = PendingIntent.getActivity(context,
                        0, displayIntent, PendingIntent.FLAG_UPDATE_CURRENT);


                Notification notification = new Notification.Builder(context)
                        .setSmallIcon(R.mipmap.ic_launcher)
                        .setContentTitle("Hello")
                        .setContentText("Hello, how are you?")
                        .setContentIntent(displayPendingIntent)
                        //.extend(new Notification.WearableExtender()
                         //       .setDisplayIntent(displayPendingIntent))
                        .setSound(alarmSound)
                        .build();

                NotificationManagerCompat notificationManager =
                        NotificationManagerCompat.from(context);
                notificationManager.notify(25454, notification);

            }
        });

0 个答案:

没有答案