• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AppWidget problem

 
Jeremy Lee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm new to the android platform and am reading the book Android application development for dummies, sorry if this is a silly question!

My problem:

From my understanding (refering to the code below), when the app widget updates itself,

1. the onUpdate() method is called

2. an explicit intent starts a toggleService

3. onHandleIntent() method in toggleService is called

4. Line 47-53 executes, causing the phone to be turned to normal mode if it was in silent mode and vice versa if the opposite was true.

So i changed the updatePeriodMillis value to 100 but the phones ringing mode wasn't changing every minute.

I know this is the desired outcome but would like to understand why the ringing mode doesn't change every minute.


After reading up on the Android developers website I was wondering if the update intent and any incoming intents must pass through the onReceive() method first.

Then, since the intents that should trigger the toggle service should have no action data, line 19 would be executed only for such intents.

Does this meant that update intents have action data? And if line 21 is executed, will onUpdate() run after that?

(public abstract void onReceive (Context context, Intent intent)
Since: API Level 1

This method is called when the BroadcastReceiver is receiving an Intent broadcast. During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.)


Thanks in advance to anyone patient enough to help with this noobish problem x).


 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think AppWidgets will not get updated more often than once every 30 minutes. If you need more frequent updates you need to set up a repeating alarm using the AlarmManager, and then handle the alarm intent in your widget's onReceive method.
 
Jeremy Lee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Mr Dittmer, that wasn't what i meant to ask though, am aware about the AlarmManager class.

Think my question was too vague.

Shall go read up more, thanks anyway!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic