I have a AlarmManager that should perform a setRepeating, but it isn't
executing the code inside my app's onRecieve. I can't figure out why for
the life of me. Any suggestions? Thank you so much in advance!
Set up the AlarmManager:
public class MainActivity extends Activity {
>
> @Override
>
> public void onCreate(Bundle savedInstanceState) {
>
> super.onCreate(savedInstanceState);
>
> setContentView(R.layout.activity_main);
>
>
>
> Log.d("Restart", "First");
>
> Intent toRun = new Intent("com.appName.restart.AlarmRestart");
>
> PendingIntent pendingToRun = PendingIntent.getBroadcast(this, 0,
> toRun, 0);
>
> AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
>
> am.cancel(pendingToRun);
>
> am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 10000L,
> 10000L, pendingToRun);
>
>
> Log.d("Restart", "Second");
>
}
>
The BroadcastReciever
public class AlarmRestart extends BroadcastReceiver {
>
> @Override
>
> public void onReceive(Context context, Intent intent) {
>
> Log.d("Restart", "Third");
>
> }
>
adb shell dumpsys alarm:
com.appName.restart
75ms running, 17 wakeups
17 alarms: act=com.apppName.restart.AlarmRestart flg=0x4
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en