我有一个创建通知的类。类是这样的:
public class TimeAlarm extends BroadcastReceiver {
NotificationManager nm;
@Override
public void onReceive(Context context, Intent intent) {
nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "Scheduled Training";
CharSequence message = "Please attend the scheduled training";
//Intent notifyIntent = new Intent();
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
Notification notif = new Notification(R.drawable.ic_launcher,
"NeuroQ Scheduled Training", System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
nm.notify(1, notif);
}
}
我有一个名为:QuizScreen的活动,单击通知时需要打开它。我试过使用:
Intent quiz_intent = new Intent(TimeAlarm.this, QuizScreen.class);
TimeAlarm.this.startActivity(quiz_intent);
但我收到此错误:
The constructor Intent(TimeAlarm, Class<QuizScreen>) is undefined
我哪里错了?我应该如何解决这个问题?