Android Wear通知显示最小化

时间:2014-07-27 21:36:47

标签: android wear-os

我不确定我做错了什么,通知是我喜欢的方式,但我不能让它让手表振动,并且显示为最小化。我想要实现的效果应该看起来像环聊通知,它会振动并全屏显示。这是我使用的代码(在手表上):

Intent actionIntent = new Intent(this, ConvActivity.class);
            actionIntent.putExtra("num",num);
            PendingIntent actionPendingIntent =
                    PendingIntent.getActivity(this, 0, actionIntent,
                            PendingIntent.FLAG_UPDATE_CURRENT);

// Create the action
                NotificationCompat.Action action =
                        new NotificationCompat.Action.Builder(R.drawable.ic_launcher,"Reply"
                                , actionPendingIntent)
                                .build();
            NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
            bigStyle.bigText(body).setBigContentTitle(name);


            NotificationCompat.Builder notificationBuilder =
                    new NotificationCompat.Builder(this)
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setContentTitle(name)
                            .setContentText(body)
                                    //.setContentIntent(viewPendingIntent)
                                    //.addAction(R.drawable.ic_map,
                                    //        getString(R.string.map), mapPendingIntent)
                            .setStyle(bigStyle).setAutoCancel(true)
                    .addAction(R.drawable.ic_launcher,"Reply"
                            , actionPendingIntent);

            if(pic != null)
                notificationBuilder.setLargeIcon(BitmapFactory.decodeByteArray(pic,0,pic.length));
                            //.extend(new NotificationCompat.WearableExtender().addAction(action))                ;




            // Get an instance of the NotificationManager service
            NotificationManagerCompat notificationManager =
                    NotificationManagerCompat.from(this);

// Issue the notification with notification manager.
                notificationManager.notify(0, notificationBuilder.build());

1 个答案:

答案 0 :(得分:5)

只有振动/声音的通知才会震动Android Wear设备并显示更多文字。

您应该考虑使用NotificationCompat.Builder.setDefaults()方法:

// Light, sound, and vibrate
builder.setDefaults(Notification.DEFAULT_ALL);
// Just sound
builder.setDefaults(Notification.DEFAULT_SOUND);
// Just vibrate
builder.setDefaults(Notification.DEFAULT_VIBRATE);