I have a class for creating notifications. The class is like this:
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);
}
}
I have an activity called: QuizScreen, which is required to be opened when the notification is clicked. I have tried using:
Intent quiz_intent = new Intent(TimeAlarm.this, QuizScreen.class);
TimeAlarm.this.startActivity(quiz_intent);
But I am getting this error:
The constructor Intent(TimeAlarm, Class<QuizScreen>) is undefined
Where am I going wrong? How should I solve this issue?
use
Intent quiz_intent = new Intent(context, QuizScreen.class);instead ofIntent quiz_intent = new Intent(TimeAlarm.this, QuizScreen.class);For example,