Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable "Transition Animation Scale" in "Developer Options" programmatically ?

I have some animation transitions for my activities. So when an activity starts, it comes up with some fade animations. Here is the code:

Intent intent = new Intent(this, NextActivity.class);
startActivity(intent);
overridePendingTransition (android.R.anim.fade_in, android.R.anim.fade_out);

The Problem is that, these animations will not run when "Transition Animation Scale" in "Developer Options" is off. So I'm searching for a way to enable this feature programmatically to ensure that my animations shown. Is There a way to set "Transition Animation Scale" to "Animation scale 1x"?

like image 670
Milad Faridnia Avatar asked Nov 19 '14 07:11

Milad Faridnia


People also ask

What is animation scale in developer options?

Three of the most useful settings under the Developer Settings section are the animation scale settings. These can let you increase or decrease the duration of window and transition animations, and in some cases, will make your phone appear to perform faster.

Is it good to remove animation in Android?

The Android operating system often uses animations when you interact with your device. For instance, it might shrink apps into the background when you close them. If you are sensitive to these visual effects, you can use the Remove animations setting to turn them off.

Does turning off animations improve performance?

Disabling the animations would give you at least this advantage: you'll save some work of your CPU (or even the GPU) that will not have to do this task (of animating things on the screen) anymore.


1 Answers

After a few days searching I have found the code which can enable (or disable) "Transition Animation Scale".

        Settings.Global.putInt(getContentResolver(), Global.TRANSITION_ANIMATION_SCALE, 1);

But there is a big problem with this code And if you ask whats the problem? I would tell this line of code needs this permission:

<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>

which is only granted to the system Apps. So your app must be a system app.

This question is about making a system application : How to make my application system

UPDATE

and as @TripeHound said, we can

Display a dialog telling the user that the app will look much nicer if they turn this option on (with an option to not display the message again if they really want it off)

How to open developer options settings?

This way:

startActivityForResult(new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS), 0);
like image 69
Milad Faridnia Avatar answered Oct 17 '22 02:10

Milad Faridnia