gpt4 book ai didi

显示最小化的 Android Wear 通知

转载 作者:行者123 更新时间:2023-11-29 15:15:17 27 4
gpt4 key购买 nike

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

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());

最佳答案

只有振动/声音通知才会使 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);

关于显示最小化的 Android Wear 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24985904/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com