Java 通知可以';不要跳到另一个活动?
我的代码是Java 通知可以';不要跳到另一个活动?,java,android,Java,Android,我的代码是 public class AlarmReceiver extends BroadcastReceiver { public Notification mNotification = null; public NotificationManager mNotificationManager = null; @Override public void onReceive(Context context, Intent intent) { Toast.makeText(conte
public class AlarmReceiver extends BroadcastReceiver {
public Notification mNotification = null;
public NotificationManager mNotificationManager = null;
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "time up!", Toast.LENGTH_SHORT).show();
mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotification = new Notification(R.drawable.icon, "tip!",
System.currentTimeMillis());
mNotification.contentView = new RemoteViews(context.getPackageName(),
R.layout.notification);
mNotification.contentView.setTextViewText(R.id.tv_tip, "click to see the description");
Intent notificationIntent = new Intent(context,NotificationTip.class);
notificationIntent.putExtra("description", intent.getStringExtra("description")) ;
//notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
mNotification.contentIntent = contentIntent;
mNotificationManager.notify(0, mNotification);
}
}
当我单击通知中的项目时,我无法进入NotificationTip活动,那么这段代码有什么问题吗?下一行
Intent notificationIntent = new Intent(context,NotificationTip.class);
需要
Intent notificationIntent = new Intent("X");
其中X是意图操作名称。您必须在android清单文件中添加作为意图过滤器。我忘了在清单文件中注册。