File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Mobile » Android
Bookmark "AppWidget problem" Watch "AppWidget problem" New topic

AppWidget problem

Jeremy Lee

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

Joined: Mar 22, 2005
Posts: 42965
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

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!
I agree. Here's the link:
subject: AppWidget problem
It's not a secret anymore!