Mark,

I think you miss understood what I mean by a reference to my Widget.

Unless I am thinking about this incorrectly. The function  onReceive
in the  OnAlarmReceiver class needs to have a reference to the widget
instance, see the below code. How else can the OnReceive function know
how many times it has fired and change its firing rate accordingly?

public class OnAlarmReceiver extends BroadcastReceiver
{
        @Override
        public void onReceive(Context context, Intent intent)
        {
                MyWidget myWidget = SomeMagicFunction();

                // Check myWidget.count to see how many times this alarm has 
fired.
                if(myWidget.count == 60)
                {
                        // We no longer want to fire once a second, we
now want to fire once a minute.
                        myWidget.alarmManager.cancel(myWidget.pi);
        
myWidget.alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime(), 1000 * 60, myWidget.pi);
                }
        }
}

I have two questions.
1) Is this the correct approach? If not then what.
2) If so then how do I do the following MyWidget myWidget =
SomeMagicFunction()

Kind regards,
Cathal

-- 
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

Reply via email to