tags:

views:

42

answers:

1

Okay, this would be fairly simple in some other environments, but I can't figure out how to do it, or if its even possible in Android.

I have placed an icon on the status bar. I would like to run a method of another class whenever the user selects that icon. I've seen similar functionality used in volume icons that sit on the status bar that allow a user to raise or lower the volume when the icon is clicked. However, these icons are on the right side of the status bar, and from what I've seen, I'm not allowed to put an icon there. I don't know if that kind of functionality is available to left side icons.

So basically, I'm looking for how to run a function when a status bar icon is clicked. I don't want to open an activity, I just want to run a function.

A: 

What you're searching is probably related to the Android UI ActionBar pattern.

Regarding that I'd like to consider you to take a look at the Google I/O 2010 Android app. It contains many of these patterns and may help you out.

Summarizing, you have to create your own ActionBar (or Status Bar as you call it). You place your buttons, retrieve them via the findViewById(...) method and associate a click listener.

Juri
Thanks for answering my question, but I don't think the ActionBar is what I'm looking for. It looks like the ActionBar is attached to an activity that my program would be running. Unlike the Twitter ActionBar example, I don't want to present anything to the user other than a persistent icon that the user can click, and I can detect that click. Do you know if that is possible.I'm trying to get the Google I/O app to run to see if it has a solution.
reggie3