Accessing the currently active activity

Put your problem here if it does not fit any of the other categories.

Accessing the currently active activity

Postby wilken » Wed Apr 15, 2009 7:17 am

Hi,
i have a service that periodically loads stuff from the net. When this happends i would like to be able to show a loader gif on the top bar of the currently active activity.

I have implemented this for now by making the service send a broadcast event, that my activities listen for, so the can update themselves accordingly.
This, however, produces a lot of annoying code, plus there is an issue when i browse away from the activity while the animation is showing.

Is there no way to do something like getContext().getCurrentlyShowingActivity() from the service?
wilken
Developer
Developer
 
Posts: 35
Joined: Wed Oct 08, 2008 8:22 am

Top

Postby padde » Wed Apr 15, 2009 7:00 pm

Well android uses sandboxing as security principle.. and accessing
a foreign activity in that kind of way would break that sandbox design.
Why dont you use the notice system? I thinks its designed exactly for
those kind of needs.

Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby wilken » Wed Apr 15, 2009 8:28 pm

padde wrote:Well android uses sandboxing as security principle.. and accessing
a foreign activity in that kind of way would break that sandbox design.
Why dont you use the notice system? I thinks its designed exactly for
those kind of needs.

Greets
Padde


Hi, the issue here is not accessing a foreign activity. I have a service running in an application. IF the application also happends to have an activity running when the service is updating, i would like to show the progress gif. it would be weird to use the notification api when the application is running (when the service is updating while there is no activity showing i use the notification api)

hope this calrifies the issue,
sincerely
Morten
wilken
Developer
Developer
 
Posts: 35
Joined: Wed Oct 08, 2008 8:22 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 15 guests