I have three activities (A, B and C) with an image view. Activity A has a small image view, B a mid-sized image view and C a fullscreen image view. From A to B I use
makeSceneTransitionAnimation for the transition. Start and Exit transition are working fine between A and B. From B to C I also use makeSceneTransitionAnimation. Thats is also working fine but when I go from C to B and then from B to A the exit transition is not working.
Is there some overriding process from C to B that affects the exit transition from B to A?
I found a solution that I am satisfied with for the moment.
My first approach was to monitor, inspect and manage the shared elements via SharedElementCallbackbut this does not seem to work as there are no shared elements in activity B when comming from C. So now when I am in activity B and I want to go to activity A, I check which activity I come from (A or C). Is it activity A then I simply use supportFinishAfterTransition. If I am coming from activity C I use makeSceneTransitionAnimation to activity A. The second case creates a new instance of activity A. Thats why I just finish the older instance of activity A.
I uploaded my solution on github to the repo "transition" in case somebody wants to use some code (github account is linked here on stackoverflow).
If somebody knows a better solution please let me know.
Related
In our app we use an activity C from a library which always should be on the top of a back stack (or should always be visible in case if being on top is impossible).
For example we have an activity A where some asynchronous job is in progress. At some moment the activity C is launched so the backstack looks like this: A -> C. When the asynchronous job in A is done it should launch the activity B in such a way that C would still be visible but B would still exist. It looks like the back stack should be like A -> B -> C or (this looks more possible) there should be two back stacks like this: (A -> B) and (C).
For now we tried some manipulations with overriding startActivity for activity A.
Are there any better ways to achieve the situation that C should be always visible until a user closes the activity?
I have come to the answer. In case you encounter this stuff as well the solution in my case looked like this:
The idea is that I save the state in the activity A after the asynchronous work which is necessary for launching the activity B. If the activity C is on top of the stack, the activity B would not be launched (done via overriding A's startActivity method). Then when the activity C is finished, activity A’s onStart method is launched. And in this method we start Activity B. Visually it looks like what I wanted to achieve.
I have one Activity with 3 fragments which form a workflow to collect user input.
Normally, Fragment A is the first fragment -> Launches B -> Launches C. B is supposed to launch A if the back button is pressed, and similarly C's Back button is supposed to launch B.
However, in some cases, A is supposed to launch C directly, and then C's back should launch A again.
I prefer that C should not know who launched it. I.e. I want C's "backstack" to operate without C knowing who launched it.
I tried using the usual addToBackstack approach, but I'm facing a problem when the Activity gets killed after the user lets the app go into the background while C was open.
I would like the user to return to "C" instead of starting all over from A. To achieve this I'm using the saved Instance state, and detecting which fragment was previously active, and launching it from the activity.
The problem starts when the user wants to go back from C, after the Activity was recreated after being killed. C doesn't know who launched it: A or B. How do I make the Back button work as expected for this case?
Found some answers in this excellent video by Android Developers + Adam Powell:
Fragments: Google I/O 2016
In summary, Fragments and the Fragment BackStack are considered part of the navigational state of the app, so, as long as I don't mess with the backstack when the activity is launched, the OS will also restore the FragmentBackStack, thus the BackStack will know who launched C (A or B) even if the activity gets re-created. Thus, popBackStack will move from C to A or B as required.
I have three activities A,B,C,D.
When I use activity B, then previous activity is A. I will write it as A->B.
So when I click back I go to A.
However I want to start activity D from B. But instead of tree A->B->D I need to alter it to A->C->D. How can do it in android?
There are many ways to do it.
You can have a lok at the below links.
First- Second- and this-
I want to create Android app where there are 3 main FragmentActivities, A (main), B, and C, also there are other sub activities. this app can go from activity A to activity B or activity C freely, and vice versa without starting new activity unless it is not started or finished. so how i can achieve this?
----- Edited -----
You can't. At any point in time there is only one Activity that is active. They will be finished and they will be garbage collected.
What you can do is set your launch mode to single task and see if it helps in your situation.
Use Navigation-Drawer or Swipe View..fragments are your solution. So you'll have FragmentActivity and 3 fragment A B C to replace
I will move activities layout to views, and write within one Activity, use hide/show to change to A, B, C.
I have an application that is based on windows principles , and doesn't not follows the android way . . .
Do not ask why , it is just an requirement, I know that should not be done that way....
Here is the problem:
I have an application that fires two transparent activities , activity A and activity B.
if activity A is shown than if the activity B should be shown the is no problem, because the activity B will be over the activity A.
But if the transparent activity B is shown then if I fire an intent the activity A will be over the activity B ,.. :(, the business logic is that if B is shown then A should be also shown but behind the A. Then is the user dismiss the B , only then the A will be visible...
I hope I describe this good, I far as I know this is not possible, but I want to ask more experienced people
if there is possibility to start some activity that will not be covered by others activities
NOTE: I am talking for preventing activities only from my application
Make A search for a special command keyword in its Intent extras, If it is found, A also launches B from its onCreate(). So, to launch A, use simple intent of A; to launch B, put the special keyword in A's intent, A will launch and also launch B.