AlarmManager: problems with set and cancel

1

I am starting to create an activity to manage alarms for an application. The problem is that when entering the set and cancel methods it says "Can not resolve symbol 'set'" and "Can not resolve symbol 'cancel'" respectively. Let's see if anyone can help me with this.

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class AlarmActivity extends Activity {

    AlarmManager alarms=(AlarmManager)getSystemService(Context.ALARM_SERVICE);

    int alarmType = AlarmManager.RTC_WAKEUP;
    long time = 10000;
    String ALARM_ACTION = "ALARM_ACTION";
    Intent intentToFire = new Intent(ALARM_ACTION);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intentToFire,0);

    //Set
    alarms.set(alarmType, time, pendingIntent);

    //Cancel
    alarms.cancel(pendingIntent);
}
    
asked by Androidvsmi 30.04.2017 в 18:41
source

0 answers