I tried and searched a lot, but did not find an answer for this. I have an activity A, transparent over an Activity B. I am trying to make the activity A scroll up to the top, like the notification bar, so that activity B becomes active. And I should be able to scroll down back A when necessary. Moreover, I am trying to implement this scrolling over an imageview in A, not anywhere on the activity A. can onTouch and onTouchListener help me? Please help me here. I am searching an answer to achieve this functionality.
You can animate Activity A to the top, saving its state, and have it start Activity B and then stop. When the user swipes down in an attempt to get back Activity A, Activity B simply starts A, which starts by animating down from the top. It restores the data it has saved, so to the user it's the same as if it has been active all the time.
If you need Activity A to continue processing, you an either delegate processing to Activity B, or to a Service, or to a class that is under control of RoboGuice and is kept active because it's injected in both A and B.
The only way I can think to do this is with Activity.overridePendingTranistion. Using this, you will have to start and finish your activity each time for it to animate. Have you considered using a view that animates down, like a SlidingDrawer?
Related
I have an activity with the bottom navigation menu.
I want to make it when I press the middle button on the menu, a small fragment pops up (doesn't fill the whole screen) and the rest of the screen gets a little bit darker and every touch that occurs outside of the small fragment I created will not be recognized as a touch in the other background fragment but instead will destroy the small fragment.
I created the small fragment and called detach and attach to the background fragment when I create and destroy the small one. However, it doesn't call the onPause and onResume functions in the fragments so it doesn't work. Also, I don't know how to make it that if I press outside of the fragment, it gets destroyed.
Can anyone help me?
That's what I'm trying to achieve:
I am currently writing a drawer layout as my main layout, with an embedded FrameLayout that I will be using to hold each “page” when an item on the drawer is clicked on. When the app first starts, an initial fragment will be show. Other fragments may be added/replaced later which is fine, however, my problem is that when the user clicks the back button on the very first “initial fragment”, I don’t want that particular fragment to be removed from the layout. Currently, it is being removed and it’s just showing a drawer layout with no other content (which makes sense). I want the app to automatically exit if the initial fragment was the last one showing and the back button is pressed, instead of removing that initial fragment and then after another back press, then it exits.
Things I have thought of doing:
Not adding the first fragment to the backstack. (If I do this, I can compare it with the classname of the fragment which is a somewhat longer string, or I can use a boolean value for once the first fragment has been placed (and not added to backstack), the boolean is set which allows the fragments to now be added.
Overriding the onBackPressed function of the activity
Does anyone have a suggested way of doing this or can think of a better way? Thanks
The first bullet point sounds the cleanest. You have no other need to handle conditions when back is hit, correct? If that's the case, it's less lines of code (removing one as opposed to adding several) and you get to keep default Activity methods as is.
I know that's not exactly what you asked, but I think the first bullet point is so clean, that I just wouldn't try something else.
I have implemented same in one of the app using my own Stack of fragment. and also implemented onBackPressed method.
Every time when user clicks on item in drawer i add fragment in stack and in back press once its length is 1 I finish the activity with message.
On item click -- Add/replace fragment in container.
OnBackPressed -- Pop fragments from stack and once its last one i finish activity.
Hope this can give you another option to consider.
I know you should use services, backgroundtasks and AsynTask for long running processes. I've also seen this and this.
is there any way to start a activity in background and when process finishes, change the activity to current activity?
Suppose I have two activity A and B.
When user clicks on a view(a item in bottom navbar for example) on activity A, the desired action is to animate that view then start activity B.
But the problem is that there is a lag between animation terminate and starting of Activity B.
What I'm thinking of is to setup activity B while the view in activity A is animating.
As soon as animation terminates the activities swipe smoothly.
Is there a possible solution for this?
I have one activity with ListView and 2nd activity which have ViewPager. Now I want in one activity if status true then go to 2nd activity `
Intent n = new Intent(one, two);
startActivity(n);`
But here problem is it giving opening animation is any i can do within that 1st activity
any way i can avoid that animation and it look like it is same activity
or i have to redo full code and this inside 2 fragments ? so have one fragment activity and then but one activity code inside fragment and two activity inside fragment which will have view pager.
Paraphrasing you, your are trying to call activity B from activity A, based on a result, which is an item picked from list item, however you wanna avoid any sort of screen transitions (animations) when moving from one another.
I may be wrong but my google search didn`t revealed any way to avoid transition between activities.What your could actually do is to refactor your code using fragments and sort them out within the parent activity view group in a way that fragment B maximizes itself or pops up over fragment A pausing it.
Brs.,
I have an app in which I am implementing a tab bar with 3 tabs. In first tab I am implementing multiple activities by using activity group.
In this activity group I have 5 activities. In the first activity I am having edit texts, I am getting the data into edit texts from another class and then navigating to another activity by clicking a button. When I am coming back from second activity to first activty I am not able to see the selected data. It is showing the page without selected data.
I don't understand this.
From the documentation:
This class is deprecated...
And now coming to your question, you said:
... When i am coming back from second activity to first activty i am not
able to see the selected data...
It is default behavior of ActivityGroup, when you move forward, your current Activity's state is not saved and when you come back to previous Activity, it is started again and onCreate() is called again.
its because, in Activity Group Implementation, all the activities are re-created and then generates view, and then adding this view in window activity is displayed. So, everytime a new activity is displayed, as activities are re-created.