开发者

How to hide activity GUI in android 2.2

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!


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.


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜