わかりましたので、私が見つけることができるすべてを試しましたが、うまくいきません。これが私のコードです。レシーバーを呼び出さない理由を誰か教えてもらえますか?
AndroidManifest.xml
...
<receiver android:name=".AlarmReciever" />
...
AlarmReceiver.java
public class AlarmReciever extends BroadcastReceiver
{
private static final Logger LOGGER = Logger.getLogger(LogService.class);
@Override
public void onReceive(Context context, Intent intent)
{
LOGGER.debug("BroadcastReceiver, in onReceive:");
}
}
DeviceMonitor.java
public class DeviceMonitor extends Service
{
public int onStartCommand(Intent intent, int flags, int startld)
{
LOGGER.debug("alarmmanger settting from on start");
AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent I = new Intent(this, AlarmReciever.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, I, 0);
Calendar time = Calendar.getInstance();
time.setTimeInMillis(System.currentTimeMillis());
time.add(Calendar.SECOND, 5);
alarmMgr.set(AlarmManager.RTC_WAKEUP, time.getTimeInMillis(), pendingIntent);
LOGGER.debug("alarmmanger set from on start");
}
}