views:

66

answers:

3

Is there an Event that is fired when an widget becomes visible on to the homescreen. I didn't mean at install time, I mean if the user changes his homescreen by wiping the surface of the phone. The background of this question is that I setup a timer in a service inside the widget that gets updates from a url but that should stop if the widget is not on the current homescreen.

Freudi

A: 

No, sorry. There are dozens of home screen applications, some of whom may not even have the concept of "wiping the surface of the phone". A home screen is merely an activity with a particular <intent-filter>.

CommonsWare
This is strange. I put the Yahoo-Currency Widget on an different homescreen. If I wipe from my default homescreen to that screen this widget starts to update its curreny data. So somehow it knows that it is visible now.
freudi_t
How do you you know it is only on the swipe that it "starts to update its currency data"?
CommonsWare
I didn't know it. I just see it. What's your guess?
freudi_t
Do you think that it is updating all the time and I just think that it is done when I activate it? BTW. I have a Desire with HTC Sense but I can see the same effect on my Android 2.1 Emulator. I will try to check out if the yahoo-widget keeps updating when it is on an invisible screen.
freudi_t
I believe the app widget is updating all of the time. If you have solid evidence to the contrary, let me know!
CommonsWare
I will try to find it out in my development machine. The expierence are from my real mobile. In my developing machine I have a lot more informations whats going on.
freudi_t
A: 

There is a way to do that, you can listen to Intent.ACTION_USER_PRESENT broadcast and update your widget on receiving the intent.

It will be fired when the user unlocks the home screen.

I am using it in my app and works great to update your widgets upon unlock.

srinathhs
A: 

Not sure if this helps, but I stumbled across this..

WallpaperManager.setWallpaperOffsets() and WallpaperService.onOffsetChanged()

Perhaps you could use this? Set wallpaper offsets and use onOffsetChanged() to get current offsets?

Snailer