how to disable or delete animations in android app, java.?

-1

I am developing an application for my work, only that there are certain animations that the app makes when changing activities that make certain processes a little tedious or slow for the smartphone.

How could you disable the animations that occurred in the app? (either change of activity or of any kind). I would like it to be as dry as possible (I do not know if you can give me to understand).

For more detail: The plan is that you can disable animations like in "programmer mode" of android, but only for the app.

Since my main activity starts like this:

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

and then the same example with the following activity

Here I complete the code:

public class MainActivity extends AppCompatActivity {
   final static String tag = "Main Activity";
   DatabaseHandler dbh;
   private ListView prodListView;
   String sname,scode,subic,sdate,salert,sid;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Action bar--------------------------
    ActionBar act = getSupportActionBar();
    act.hide();
    //------------------------------------


    prodListView = findViewById(R.id.mainslist);
    dbh = new DatabaseHandler(this);
    final Button btn_options = findViewById(R.id.btnSettings);
    final Button btn_products = findViewById(R.id.btnProducts);
    final Button btn_search = findViewById(R.id.btnBusqueda);
    filllistview();
    setToday();

The fact is that if I start another activity it does a very basic animation where the other activity is superimposed on the previous one, exactly that is what I do not want to happen.

this is the way I call an activity:

  btn_products.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
              Intent prod = new Intent(getApplicationContext(),Productos.class);
            startActivity(prod);
        }
    });
    
asked by Kevin Mora 10.12.2018 в 21:46
source

2 answers

0

Actually the animations should not be a problem, each operating system shows animations when making transitions between Activities, you comment that your application is "slow", in reality this must be due to another problem.

According to what you comment, it seems to me that you are opening several Activity, which can cause a high memory consumption and consequently "slowness".

I suggest you use the finish() method to finish the Activity that will start a new Activity and this will free resources.

btn_products.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
              Intent prod = new Intent(getApplicationContext(),Productos.class);
              startActivity(prod);

              finish();
        }
    });

Disable animations between Activity transitions.

If you want to disable the animations you can use the Flag:

intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

Example:

Intent intent = new Intent(this, Productos.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityForResult(intent, 0);
overridePendingTransition(0,0);
    
answered by 10.12.2018 / 23:49
source
0

To disable the animation when starting activity:

Intent intent = new Intent(activity, UserSearchActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
activity.startActivity(intent);

Y:

activity.overridePendingTransition(0, 0)
    
answered by 11.12.2018 в 00:02