Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - display a persistent view over all activities

Tags:

android

I'd like to recreate a functionality similar to a Swing GlassPane to be able to display animations while the user uses the app "below" normally. I cannot simply create a separate layout and attach it to each activity since the animation state would be lost when switching activities. Is there a way to keep a persistent view over all the activities of an Android application ?

Thanks.

like image 380
janin Avatar asked Mar 04 '11 14:03

janin


People also ask

What is the difference between View and activity in Android?

View is Display System of Android where you define layout to put subclasses of View in it eg. Buttons, Images etc. But Activity is Screen System of Android where you put display as well as user-interaction,(or whatever which can be contained in full-screen Window.)

What is Flag_activity_new_task in Android?

The flags you can use to modify the default behavior are: FLAG_ACTIVITY_NEW_TASK. Start the activity in a new task. If a task is already running for the activity you are now starting, that task is brought to the foreground with its last state restored and the activity receives the new intent in onNewIntent() .

What is Android activity lifecycle?

An Android activity goes through six major lifecycle stages or callbacks. These are: onCreate() , onStart() , onResume() , onPause() , onStop() , and onDestroy() . The system invokes each of these callbacks as an activity enters a new state.

Which callback is called when the activity is no longer visible?

onStop() When your activity is no longer visible to the user, it has entered the Stopped state, and the system invokes the onStop() callback. This may occur, for example, when a newly launched activity covers the entire screen.


1 Answers

No its not. Every Activity runs in its own thread and is by design supposed to be runnable standalone.

But you could persist the animation state into the DB or into sharedPreferences and start it over at the new activity.

What you could also do is to use a Spinner or another control instead of seperate activitys. Then you could have a persistent view.

like image 93
Chris Avatar answered Sep 27 '22 16:09

Chris