0
我正在尝试将特殊操作添加到通知中,以便我可以使用智能手表来远程控制应用程序。智能手表通知及行动
这是我当前的代码:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("Control Notification");
builder.setContentText("With this notification I should be able to control the app with my watch.");
builder.setSmallIcon(R.drawable.ic_launcher);
Intent actionIntent = new Intent(this, MainActivity.class);
actionIntent.putExtra("action", true);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, actionIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.ic_launcher, "action", resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0, builder.build());
的问题是,每次我火我的手表一个新的活动打开了我的手机上的动作。但我想重复使用旧的活动。我需要改变什么?顺便说一下:如果您有任何其他关于我的代码的提示或改进,请随时告诉我。