Android animate to singleTask - android

I am making an app with multiple tabs (without the tabview). One takes a long time to load so I made a singletask of it. Now it only has to load once what saves a lot of time.
Only in the onCreate I define the transition I want:
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
Only the onCreate is never called again, i tried to put it on top of the onResume and onStart but that didn't helped either.
The problem now is that the animation becomes the default animation which differs a lot on different devices.
Does anyone know a way to change this? I tried calling it after the startActivity method with no succes either.
If anyone has a solution to stop the loadtime then it is also okey.
The load time goes to making multiple listview in a swipeview (jason fry). This listview contains around 90 imageviews each, most of them are the same image.
Thanks for any thoughts, ideas or solutions in advance.

You should override the finish() method of your activity.
In the overridden method, after calling super.finish() - call overridePendingTransition() with your favorite transition (if you want no transition - define a transition that does nothing, with duration 0).

You could try calling that in the onNewIntent() method. That should be called when you try to launch the Activity a second time.

Related

Performance issue when calling setRequestedOrientation

I have vertical android app with many fragments inside just one activity. At some point I'm having user the sign. Thus I rotate device using following code at onCreateView and onDestroyViewof signature fragment.
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
((AppCompatActivity) getActivity()).getSupportActionBar().show();
However, it takes too much time to replace fragment, sometimes more than 2 seconds, and even I put waiting dialog on nextPage button click, It's not showing the dialog. (Even there is no function inside of nextPage button but replace fragment function)
I think It's about CPU, but didn't understand which column (Inclusive Time, Exclusive Time etc) is related to it. Here is screenshot;
Any idea about solution or what is causing this?
Thanks.

How to do activity transtion?

I have implemented one App which has many activities.. . I want to implement one activity as left and right and vice versa in fling transition manner between whole activity. For example
SO when you hit next there should be transition between next activity and when you hit previous there should be transition between previous . How should i Implement this?. ... Its fling but not with touch, but using those buttons...
Check out ViewFlipper (video demo here), ViewPager, or ViewPagerIndicator.
Define translation animations in xml then use overridePendingTransition BEFORE setContentView in each Activity. E.g. overridePendingTransition(R.anim.slidein, R.anim.slideout); You probably need to put this in onResume if you want it to work both ways (i.e. when you're going from and back to that Activity.).

Android restore animation on activity resume

I have an activity where i do a scale animation on a view when a button is clicked.
I have set fillAfter as true for the animation.
When the animation is done, I start another activity. The problem is when I go back to my original activity, my scaled view is back to its original size.
Is there anyway to leave the activities content view the way it is when we start another activity?
I read the saveInstanceState, but most posts over here refer to saving values and not the UI. Im not really sure how to tackle this issue in a efficient way.
Or should I save the scaled view and restore it on the onResume function of the activity?
I was able to solve this issue by adding the launchMode attribute in the manifest file.

Calling setContentView for animation

In my application we are achieving the page-animation by using setContentView every time the animation occurs. The layout contains just an image so its definitely not too heavy. But are there any other problems in calling setContentView again and again on the same activity. Will it cause memory leaks or something similar.
Tried searching the net but since our layouts contain only the imageviews the onSaveInstance also doesn't have much to do.
Let me know your inputs.
PS I know about ViewFlippers and other waqys of animation. Was just curious if its advisable not to call setContentView in an activity repeatedly and Why?
And I can't create a tag for setContentView if any of you can please tag this question with that tag.

Android: How to start an infinite animation applied on an ImageView after the Activity with the animated View has been resumed?

I just read this:
Android: How can I stop an infinite animation applied on an ImageView?, I tried it and it works perfectly, I set the animation in the onCreate() method of my Activity using AnimationUtils.loadAnimation(AppContext, animationRes), then I start the animation using startAnimation() and stop it using clearAnimation(). The problem I've got is that if I start another activity and then go back to the one with the animation, it doesn't work anymore. It looks like the animation is not even started, the listener attached to the animation doesn't enter the onAnimationStart(). Am I missing something here?
Thanks!
Where are you calling clearAnimation().
IMHO, I think you have to call startAnimation() at onResume() and call 'clearAnimation()' at onPause().
Check it out and tell us.

Categories

Resources