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"?
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);