我正在通过以下方式从我的手机上的应用程序创建通知。
private void launchMicroAppFromWearableNotif() {
int notificationId = 001;
// The below action has been defined in the micro app
Intent i = new Intent("com.microapp.action.PLAY_MUSIC");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent playPendingIntent =
PendingIntent.getActivity(this, 0, i, 0);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.play_music)
.setContentTitle("Play Music")
.setContentText("Play Music on Wear")
.setContentIntent(playPendingIntent)
.addAction(R.drawable.play_music, getString(R.string.act1), playPendingIntent);
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());
}
我创建了一个可穿戴微型应用程序,它有一个活动(PlayActivity) ,在可穿戴清单中定义了动作“com.microapp.action.PLAY_MUSIC” 。
当我从可穿戴设备的通知中采取行动时,我希望微应用程序的活动能够启动。但什么也没有发生。有人可以帮忙吗?这是正确的方法吗?