From 2d7ac8e7b05d0a6105f1c52b7f7f54069ce8991c Mon Sep 17 00:00:00 2001 From: Andy2 Date: Wed, 7 Dec 2011 18:33:26 -0800 Subject: [PATCH] use SystemClock.elapsedRealtime() rather than 0 as initial fire time when setting background update timer. --- .../src/org/eehouse/android/xw4/RelayReceiver.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java index 204b6f9b9..477e9f602 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java @@ -33,6 +33,7 @@ import android.content.Intent; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; +import android.os.SystemClock; import java.net.Socket; import java.io.InputStream; import java.io.DataInputStream; @@ -53,10 +54,8 @@ public class RelayReceiver extends BroadcastReceiver { RestartTimer( context ); } else { // DbgUtils.logf( "RelayReceiver::onReceive()" ); - // if ( XWConstants.s_showProxyToast ) { - // Toast.makeText(context, "RelayReceiver: fired", - // Toast.LENGTH_SHORT).show(); - // } + // Toast.makeText(context, "RelayReceiver: fired", + // Toast.LENGTH_SHORT).show(); Intent service = new Intent( context, RelayService.class ); context.startService( service ); } @@ -83,7 +82,10 @@ public class RelayReceiver extends BroadcastReceiver { PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 ); if ( force || interval_millis > 0 ) { - long first_millis = force ? 0 : interval_millis; + long first_millis = SystemClock.elapsedRealtime(); + if ( !force ) { + first_millis += interval_millis; + } am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP, first_millis, // first firing interval_millis, pi );