Inconsistent Alarm Behavior

by Kevin » Thu, 29 Apr 2010 07:16:59 GMT

Sponsored Links
  have an inexact alarm that is supposed to launch a service to update
some data every hour, but it only seems to work at most 50% of the
time. I thought I did the wake lock correctly, but perhaps not.
Here's the relevant code, if anyone can give suggestions it would be
greatly appreciated.

public class TwitterAlarmReceiver extends BroadcastReceiver
public static final String ACTION_REFRESH_TWITTER_ALARM =

public void onReceive(Context context, Intent intent)
/* Create the wakelock if necessary */
if ( TwitterUpdateService.wakeLock == null )

PowerManager pm =
TwitterUpdateService.wakeLock =
pm.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "TwitterUpdateService
Wake Lock" );
TwitterUpdateService.wakeLock.setReferenceCounted( true

/* Aquire the wake lock */

// TODO Fire alarm on next network connection after firing once
airplane mode.
Intent startIntent = new Intent( context,
TwitterUpdateService.class );
context.startService( startIntent );

public class TwitterUpdateService extends Service
public static PowerManager.WakeLock wakeLock;
public static final String TWITTERS_UPDATED = "twitters_updated";
public void onCreate()
Intent intentToFire;
String alarmAction;

/* Initialize the connection information objects */
connManager =
(ConnectivityManager)getSystemService( Context.CONNECTIVITY_SERVICE );
netInfo = connManager.getActiveNetworkInfo();

/* Create the recurring alarm */
alarms = (AlarmManager)getSystemService( Context.ALARM_SERVICE
alarmAction = TwitterAlarmReceiver.ACTION_REFRESH_TWITTER_ALARM;
intentToFire = new Intent( alarmAction );
alarmIntent = PendingIntent.getBroadcast( this, 0, intentToFire,
0 );

public int onStartCommand( Intent intent, int flags, int startID )
SharedPreferences prefs;
int alarmType, frequency;
long timeToRefresh;

prefs = PreferenceManager.getDefaultSharedPreferences( this );
/* Default update period is once a day */
frequency =
Integer.parseInt( prefs.getString( "twitter_update_interval",
"60" ) );

/* Wakeup when this alarm fires */
alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP;
/* User selected interval in minutes converted to milliseconds
timeToRefresh = SystemClock.elapsedRealtime() + frequency * 60 *
/* Inexact is ok */
alarms.setInexactRepeating( alarmType, timeToRefresh,

Other Threads

1. WindowManagerService Animation problem

Hi guys, i tried to change the "task_open_enter.xml". This file
describe the animation used to open a new activity.

the original:
<set xmlns:android=""
        <translate android:fromXDelta="33%" android:toXDelta="0"

I change to:
<set xmlns:android=""
        <rotate android:fromDegrees="0.0" android:toDegrees="180.0"
android:pivotX="50%" android:pivotY="50%"

after that, when opening a new activity, the animation just goes
really strange, it doesn't rotate on center of the screen

If i want to make the screen animate 180 degress with pivot position
on a center of the screen, are there any better idea ?

Please help ....



2. How to Obtain Endless Views

I am developing an application in which a user keeps on scrolling and
each view displays a single text. The views are not suppose to end.
How can i achieve that?

Hope my question is clear.Waiting for the reply

3. Service running or not ?

4. Sense UI for 32A

5. Student Education Loan

6. ListView vs. ListActivity different default behavior

7. Where have all the Google employees gone?