i use SharePreference to set up a group Alarm. in the whole every thing is good, but i want to cancel the Alarm with btn\_cancel , but it doesn't.(although i use StopService, but nothing happen!). please help me what can i do?

```
public class MyActivity extends Activity implements View.OnClickListener {

private static final String SHARED_PREFERENCES_NAME = "ALARM_NOTIFICATION";  
public static final String REQUEST_CODE = "REQUEST_CODE";  
public static final String TIME = "TIME";  
public static final String ALARM_1_NAME = "ALARM_1"; 
public static final String ALARM_NAME = "ALARM_NAME"; 

public static  TextView text1;
private Button set1;

public static long timer1 = 0; 
private int requestCode = 0;
private Intent intent1 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    set1 = (Button) findViewById(R.id.btn_set1);
    alarmLinear = (LinearLayout) findViewById(R.id.alarmLayout);
    text1 = (TextView) findViewById(R.id.add1);

    set1.setOnClickListener(this);
    text1.setOnClickListener(this);
    findViewById(R.id.btn_cancle1).setOnClickListener(this);

}

@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.add1: {
            set1.setVisibility(View.VISIBLE);

            if (timer1 == 0) {
                timer1 = getCurrentTime();
            }  // get time from system
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(timer1);  //set time in timer parametr

            TimePicker timePicker = (TimePicker) findViewById(R.id.tp_1);
            timePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
            timePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));

            break;
        }
        case R.id.btn_set1: {
            TimePicker timePicker = (TimePicker) findViewById(R.id.tp_1);
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
            calendar.set(Calendar.MINUTE, timePicker.getCurrentMinute());
            calendar.set(Calendar.SECOND, 0);
            timer1 = calendar.getTimeInMillis();

            String stringTime = convertTimeToString(timer1);
            text1.setText(stringTime);

            if (intent1 == null) {
                intent1 = new Intent(this, alarmService.class);
                intent1.putExtra(ALARM_NAME , ALARM_1_NAME);
            }
            requestCode++;
            intent1.putExtra(REQUEST_CODE, requestCode);
            intent1.putExtra(TIME, timer1);
            startService(intent1);
            break;
        }
        case R.id.btn_cancle1:
            cancelTimers();
            break;

    }
}

private long getCurrentTime() {
    Calendar calendar = GregorianCalendar.getInstance();
    return calendar.getTimeInMillis();
}

private void cancelTimers() {
    if (intent1 != null) {
        timer1 = 0;
        stopService(intent1);
        text1.setText("+");
    }
}

```

And this AlarmService() class:

```
public class alarmService extends Service {
@Override
public IBinder onBind(Intent intent) {
    throw new UnsupportedOperationException("Not yet implemented");
}

public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent == null) {
        stopSelf();

    } else {
        String alarmName = intent.getExtras().getString(MyActivity.ALARM_NAME);
        Intent alarm = new Intent(this, alarm.class);
        alarm.putExtra(MyActivity.ALARM_NAME,alarmName);

        int requestCode = intent.getExtras().getInt(MyActivity.REQUEST_CODE);
        long time = intent.getExtras().getLong(MyActivity.TIME);

        PendingIntent pendingIntent1 = PendingIntent.getBroadcast(this, requestCode, alarm,
                PendingIntent.FLAG_UPDATE_CURRENT);

        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        long currentRTC = System.currentTimeMillis();
        if (currentRTC <= time) {
            alarmManager.set(AlarmManager.RTC, time, pendingIntent1);
        }

    }
    return START_STICKY;
}

```

}

thanks.