This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Android and the fly likes AppWidget problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "AppWidget problem" Watch "AppWidget problem" New topic
Author

AppWidget problem

Jeremy Lee
Greenhorn

Joined: Jan 26, 2011
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
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.


Ping & DNS - my free Android networking tools app
Jeremy Lee
Greenhorn

Joined: Jan 26, 2011
Posts: 5
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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: AppWidget problem
 
Similar Threads
Are There a way to know if the internet(not network) disconnected
send scheduling sms through android
Start activity in broadcast receiver
AutoStart App on Device BootUP
Application not run in the background