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());
的問題是,每次我火我的手錶一個新的活動打開了我的手機上的動作。但我想重複使用舊的活動。我需要改變什麼?順便說一下:如果您有任何其他關於我的代碼的提示或改進,請隨時告訴我。