tags:

views:

143

answers:

0

Toast.makeText(context, "Alarm Worked", Toast.LENGTH_LONG).show(); NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon, "Wake up alarm", System.currentTimeMillis()); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, ScheduleActivity.class), 0); notification.setLatestEventInfo(context, "Task", "DO IT!", contentIntent); notification.flags = Notification.FLAG_INSISTENT; manager.notify(NOTIFICATION_ID, notification);

So the above code is what I have in my onReceive() method in my receiver. It currently sends a notification to the status bar however I need it to be more verbose, I need it to either fire up an intent, or pop up a huge dialog box with the options "Go to app" and "ignore notification". So pretty much I need this:

Intent starter = new Intent(context, ScheduleActivity.class);  
startActivity(starter);

or this:

AlertDialog.Builder toDo = new AlertDialog.Builder(context);
toDo.setTitle("To Do");
toDo.setMessage("You need to do something.");
AlertDialog ad = toDo.create();
ad.requestWindowFeature(Window.FEATURE_LEFT_ICON);
toDo.setNegativeButton("Ignore",new DialogInterface.OnClickListener(){
    public void onClick(DialogInterface dialog, int whichButton){
        Toast.makeText(context, "Why are you ignoring me.",Toast.LENGTH_LONG).show();
}

}); toDo.create(); toDo.show();

However, when I run it with the AlertDialog, the error I get is that because the class is not a receiver, it cannot create a AlertDialog.

If I run it with the intent, it doesn't even compile becuase it says that startActivity() is not defined for receivers.

HELP!!!