views:

71

answers:

3

Hi all, I have an activity here.

I want to click a button and then hide the activity GUI.

That is, GUI is needed and you can hide it by clicking a "Hide App" button. How can i

implement this "Hide App"?

Somebody help! Thanks in advance!

A: 

Presumably when your user clicks the hide application button, you're going to want to show something - at the very least a show button, so the user isn't stuck without input options!

So what you really have then is two views, one with the GUI hidden.

Two approaches I can see:

  • Hide app calls another activity with only the UI shown that you want. When the activity is finished, use Activity.finish() to return to the original activity with the GUI
  • Look at ViewAnimator and its subclasses (ViewFlipper and ViewSwitcher)
SamStephens
+1  A: 

To do what you want within the organizational model of android, your "program" should be written as a service, not an activity. You would then have a gui that is an activity and a client of your service, which can be started (made visible) and paused/stopped (hidden) as desired.

Chris Stratton
thanks for your reply. I'll try that
A: 

You could also just enable the screen lock. ;-)

That would automatically lock the screen (hide your app). And when the user unlocked the screen (using the UI and a gesture the user is already very familiar with) he would automatically get back into your app without you needing to do any extra coding.

The additional advantage of the screen lock is that it can be be password-protected, so if the user has his screen-lock already set to a password, instead of a slide bar -- he would just get the slide password thingy.

Stephan Branczyk