Android 警报不工作

Android 警报不工作,android,Android,我编写以下代码。 我在舱单中声明广播接收器仍然不工作。 我是一个乞丐,被困了两个小时。 这里会有什么问题 // My launcher activity public class AlarmMainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) {

我编写以下代码。 我在舱单中声明广播接收器仍然不工作。 我是一个乞丐,被困了两个小时。 这里会有什么问题

// My launcher activity
public class AlarmMainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
        GregorianCalendar gc=new GregorianCalendar();
        gc.set(2012, 1, 14, 11, 28);

        Intent intent=new Intent(this, AlarmService.class);
        gc.set(Calendar.AM_PM, 0);

        PendingIntent sender=PendingIntent.getBroadcast(this, 1, intent, 0);
        am.set(AlarmManager.RTC_WAKEUP, gc.getTimeInMillis(), sender);
        System.out.print(gc);
    }
}

// broadcast reciever class

public class AlarmService extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "Alarm started", 2000).show();
    }
}

欢迎来到StackOverflow。请指出您遇到的具体错误或问题,以便其他人能够帮助您。
NotificationManager nm;
@Override
public void onReceive(Context context, Intent intent) {
    nm = (NotificationManager) context.getSystemService(
        Context.NOTIFICATION_SERVICE);
    CharSequence from = "Check your ....";
    CharSequence message = "It's time!";
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
        new Intent(), 0);
    Notification notif = new Notification(R.drawable.ic_launcher,
        "ur text", System.currentTimeMillis());
    notif.setLatestEventInfo(context, from, message, contentIntent);
    notif.defaults |= Notification.DEFAULT_SOUND; 
    notif.flags |= Notification.FLAG_AUTO_CANCEL; 
    nm.notify(1, notif);