alarm dosen't play android
<p>I try to implement alarm in my android application, this is my code below, I don't know where I did it wrong,  please help, thanks.</p>

<p>OnetimeAlarmReceiver.java
         import android.content.BroadcastReceiver;</p>

<pre><code>      import android.content.Context;
       import android.content.Intent;
        import android.widget.Toast;

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

            }

NoteEdit.java

              private int alarm=1;
         public void setAlarm() { 
    if(alarm!=1){
        alarmTime.set(Calendar.YEAR, dateAndTime.get(Calendar.YEAR));
        alarmTime.set(Calendar.MONTH, dateAndTime.get(Calendar.MONTH));
        alarmTime.set(Calendar.DAY_OF_MONTH, dateAndTime.get(Calendar.DAY_OF_MONTH));
        alarmTime.set(Calendar.HOUR_OF_DAY, dateAndTime.get(Calendar.HOUR_OF_DAY));
        alarmTime.set(Calendar.MINUTE, dateAndTime.get(Calendar.MINUTE)-alarm); 
        alarmTime.set(Calendar.SECOND, 0);   
        alarmTime.set(Calendar.MILLISECOND, 0); 

    }

    Intent intent = new Intent(NoteEdit.this, OnetimeAlarmReceiver.class);
    PendingIntent sender = PendingIntent.getBroadcast(NoteEdit.this, 0, intent, PendingIntent.FLAG_ONE_SHOT); 
    //PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1234567, intent, 0);

    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime.getTimeInMillis(),  sender);
    Toast.makeText(NoteEdit.this, "Alarm set", Toast.LENGTH_LONG).show();
}
private void populateFields() {
    if (mRowId != null) {
        Cursor note = mDbHelper.fetchNote(mRowId);
        startManagingCursor(note);
        mTitleText.setText(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
        mBodyText.setText(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
}


         public boolean onOptionsItemSelected(MenuItem item) {

            case PICK_ALARM:
        final CharSequence[] items1 = {"5 minutes before", "10 minutes before", "15 minutes before","20 minutes before", "30 minutes before", "1 hour before"};
        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
        builder2.setTitle("Select your alarm");
        builder2.setItems(items1, new DialogInterface.OnClickListener() 
        {    

            public void onClick(DialogInterface dialog, int item) {   
                setAlarm(); 
                Toast.makeText(getApplicationContext(), items1[item], Toast.LENGTH_SHORT).show(); 
                if(items1[item]=="5 minutes before"){
                    alarm =5;
                }else if(items1[item]=="10 minutes before"){
                    alarm =10;
                }else if(items1[item]=="15 minutes before"){
                    alarm =15;
                }else if(items1[item]=="20 minutes before"){
                    alarm =20;
                }else if(items1[item]=="30 minutes before"){
                    alarm =30;
                }else if(items1[item]=="1 hour before"){
                    alarm =60;
                }
            }
            });
        AlertDialog alert1 = builder2.create();
        alert1.show();
        break;



        }
</code></pre>
