I am having trouble starting my pendingIntent . I have some problems using logcat, etc., and in the end I am pretty sure that my problem is really in my pendingIntent method. The times that I set are correct, and the method gets called, but nothing happens at the appointed time. Here is the method I use to create pendingIntent
public void scheduleAlarm(){ Log.d("Alarm scheduler","Alarm is being scheduled"); Intent changeVol = new Intent(); changeVol.setClass(this, VolumeService.class); PendingIntent sender = PendingIntent.getService(this, 0, changeVol, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, time, sender);
Here is the class of service:
public class VolumeService extends Service{ @Override public void onCreate() { super.onCreate(); Log.d("Service", "Service has been called."); Toast.makeText(getApplicationContext(), "Service Called!", Toast.LENGTH_LONG).show(); } @Override public IBinder onBind(Intent arg0) {
The log in the scheduleAlarm() class works as I planned, but then nothing happens, so I assume this is my pendingIntent . Thanks in advance!
source share