broadcastreceiver - Using a broadcast reciever to start AlarmManager in Android? -


i writing program fires off intent start service periodically, have decided use alarmmanager, able make wanted in activity im getting error when attempting in receiver im unable figure out.

alarmmanager = (alarmmanager)getsystemservice(alarm_service);

tells me alarm_service can't resolved variable

here complete code reciever:

    package com.testapp21.second.activities;  import android.app.alarmmanager; import android.app.pendingintent; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; import android.os.systemclock;  public class phoneonreceiver extends broadcastreceiver { private pendingintent malarmsender;  @override public void onreceive(context context, intent intent) {     malarmsender = pendingintent.getservice(context,               0, new intent(context, statscheckerservice.class), 0);      // want alarm go off 30 seconds now.       long firsttime = systemclock.elapsedrealtime();        // schedule alarm!       alarmmanager = (alarmmanager)getsystemservice(alarm_service);       am.setrepeating(alarmmanager.elapsed_realtime_wakeup,                       firsttime, 30*1000, malarmsender);  }  } 

try

alarmmanager = (alarmmanager)context.getsystemservice(service.alarm_service); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -