因此,在 Google I/O 2016 和新的 Wear 2.0 之后,我试图在我的 huawei watch running beta build 上存档相同的通知。
这里谷歌通知更改文档
我尝试从以前使用通知的方式更新,但没有运气。我只是无法在通知底部添加操作按钮。
到目前为止,我得到了什么:
Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.nav);
Intent snoozeIntent = new Intent(getApplicationContext(), SnoozeNotification.class);
PendingIntent piSnooze = PendingIntent.getBroadcast (getApplicationContext(), 1, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap resizedBitmap = Bitmap.createScaledBitmap(
background, 150, 150, false);
NotificationCompat.Action action_1 = new NotificationCompat.Action.Builder(R.drawable.ic_timer_white_24dp, getString(R.string.snooze), piSnooze).build();
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle(getString(R.string.wear_notification_1));
builder.setContentText(getString(R.string.wear_notification_2));
builder.setVibrate(new long[]{2000});
builder.setPriority(Notification.PRIORITY_MAX);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setAutoCancel(true);
builder.addAction(R.drawable.ic_timer, getString(R.string.snooze), piSnooze);
builder.setLargeIcon(resizedBitmap);
builder.extend(new android.support.v7.app.NotificationCompat.WearableExtender().addAction(action_1)).build();
builder.build();
但我只看到没有任何按钮等的正常通知。有人知道我做错了什么吗?