我有一个创建通知的类。类是这样的:Onclick通知,在Android中启动一个活动
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
我要去哪里错了?我应该如何解决这个问题?
如果你不介意,可以请你提出一些修改在发布的代码? – kittu88
它与Ankit刚才写的 –