I am developing an application that user can minimize (hide) resumed activity (but not all the application) by pushing to a button and previous one will be showed. Then, in any activity, by pushing another button, user can see the minimized (hidden) activity again with it's state.
I'm trying two way of solving this problem.
1 - When activity will be minimized(hide), all it's view's state and attributes will be stored to database after then the activity will be finished.
2 - Hold all activities in a separate task(singleInstance) and when it will be minimized, just call movetTaskToBack function.
How should i do or is there another way?
Just set the visible state of the containing layout to View.GONE (with setVisibility(). This will hide all the Views on that Activity.
Related
Hello I currently have an Activity A with a fragment inside that the user can interact with, the goal here is to simply "background" Activity A and fragment and allow the user to use the rest of the app normally with a floating button that when pressed the user will be taken back to Activity A and the UI will be restored the same as the user left it. I've looked into onSaveInstanceState but that only applies to when the system ends it or when screen rotation happens and not when the user presses the back button. So is it possible to save Activity A with the same UI and restore it at any given time?
Edit: I also have no way of accessing/modifying the fragment's components since it's coming from an SDK already.
I have one activity that keeps refreshing the elements on it based on the responses from our server, and i created another activity that overlays the 1st activity with some information i need to collect from the user if he wants, but when i pop up this 2nd activity which is transparent and shows what is in the background, the objects that were getting refreshed stopped moving because the activity went to pause mode.
Still i can see the content on the activity that is behind but nothing is moving anymore.
How can i get my 2nd activity working with the transparency and still be able to see the content of the background activity running?
You don't. An activity is paused whenever it is no longer the foreground activity- whenever any activity is launched on top of it. The transparency doesn't matter. If you don't want to be paused, don't make the new functionality an activity- make it a dialog, fragment, or an overlay of some sort.
You cannot. Android only allows one active activity at a time. So once an activity is in foreground, another activity will be placed in background and triggers onPause method. To make a transparent activity, you can make it as a dialog activity.
I am making an android app. In the action bar, I have three buttons: the up button, a button that goes to a home page (essentially a restart), and an info button that describes the app.
I have set the info button to go to an activity called 'info activity' that just has some text on it. The issue is this problem: My info activity can be triggered by multiple activities in the app, so this activity does not have one parent I can name in the Android manifest for a return. I cannot find any documentation to allow one activity to return to multiple activities, depending on which the activity the 'info activity' was accessed from and use the up button navigation to return to it. Is this impossible? Or is there another way I can do what I am attempting? It seems like one activity can only have one parent.
The "Up" navigation is designed to work in a hierarchical structure and by that, I guess that means predefined structure. It's not meant to work for dynamic, ad-hoc structures.
From Android designed guide:
The Up button is used to navigate within an app based on the hierarchical relationships between screens. For instance, if screen A displays a list of items, and selecting an item leads to screen B (which presents that item in more detail), then screen B should offer an Up button that returns to screen A.
If a screen is the topmost one in an app (that is, the app's home), it should not present an Up button.
I am writing a android application where, on startup activity view, I have a button "DoIt". When user clicks "DoIt" button, I start another activity with different layout. On newly started activity, I have a button "Back" which should take me to the first activity. How to accomplish this. What code should I write on OnClick method of "Back" button. Also, I want the newly created activity to die after back button is pressed and application comes back to start-up activity.
In the new activity you can just call
this.finish();
to return to the previous activity. If you want a result from the child activity you have to launch it with startActivityForResult() and override onActivityResult in the parent. The hard back key should always go back to the parent activity by default.
Call finish() on your activity. Also, why are you making a button on screen for this? This is usually the job of the device's back button.
In my opinion, Android is really bad on such scenario. In Activity, it doesn't support multiple views. Consider the situation that users want to switch from these two views, or even several other views? I think in this case, iPhone is much much better.
I am trying to bring an activity to the foreground from inside the activity. I am implementing multiple applications that do not cover the whole screen, so you can see other applications (activities) in the background and even touch them. The activities in the background react to the on touch event (e.g. one of its buttons is pressed), but it is not getting focus. This is what I would like to change. I want the activity to get focus and come to the foreground, whenever it is touched.
I tried to call startActivity from inside, but this resulted in either starting a new activity or no reaction at all (depending on the used intent flags). I want to achieve the exact same behavior that is shown when the activity is called from recent activities window. (the window opened when you long press the home button); bring the existing activity from the background to the foreground and focus it.
Is there a way to achieve this?
Have you tried configuring the activity in the manifest as android:launchMode="singleTop"?
This way, when you launch your activity when it is already running, a duplicate won't be started.
More info here:
https://developer.android.com/guide/topics/manifest/activity-element.html