Android中的通知

时间:2014-07-14 03:41:57

标签: android wear-os

我已经为android穿戴创建了一个通知。通知正确出来。我还在通知中添加了addAction。我有两个问题:

  1. 我不知道为什么我会得到三张幻灯片页(底部有三个点),

     a. Notificaiton text
     b. A black background image (second slide)
     c. Add action button (third slide)
    
  2. 我正在尝试点击通知以打开一个无效的新意图:

  3. 以下是我尝试的代码:

    Intent notificationIntent = new Intent(this, Wear.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    int notificationId = 001;
    Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.backgroundwatch);
    NotificationCompat.Builder notificationBuilder =
    new NotificationCompat.Builder(this)
         .setSmallIcon(R.drawable.launchericon)
         .setContentTitle("Mail ME")
         .setContentText("Are you in need of help?? Click or slide to request help!")
         .setLargeIcon(background)
         .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(background))
         .addAction(R.drawable.launchericon,"Help", contentIntent);
    

    我不确定我哪里出错了?

    谢谢!

1 个答案:

答案 0 :(得分:0)

似乎,当您使用BigPictureStyle时,它在Android Wear上显示为3页:

  1. 通常带文字的通知
  2. 仅来自.bigPicture(...)的图片
  3. Open行动
  4. 检查哪个位图实际位于R.drawable.backgroundwatch,因为您重新分配background变量两次:

    Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.backgroundwatch);