Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Screen Orientation slow?

In my Android application i have loaded some images and data from the internet into expandable list view.And i have handled orientation changes as follows.

@Override
public Object onRetainNonConfigurationInstance() {
    isOrentationChnged=true; 
    final Object data = arrGroupelements;
    return data;

}

in my onCreate()

     if(!isOrentationChnged){
    new LongRunning().execute();

}else{

      if((String[][])getLastNonConfigurationInstance()==null){
        new LongRunning().execute();
      }else{
    arrGroupelements= (String[][]) getLastNonConfigurationInstance();
    expList.setAdapter(new ExpAdapter(cont));
      }
}

isOrentationChnged=false;

LongRunning is a AsynacTask which have used to get the data from the internet and it loads previously loaded data after orientation change (without getting new data from the internet again) but it is very slow.Is there any alternative way to do this efficiently ??

like image 881
Dinesh Anuruddha Avatar asked Sep 18 '26 18:09

Dinesh Anuruddha


1 Answers

Finally i got simple way to speed up the orientation changes in an activity.

IDEA:

Each and every orientation change will recreate the activity the solution to this you can avoid the activity recreation by adding following code line to activity tag on your application's manifest file.

android:configChanges="orientation|keyboardHidden|screenSize"

above line avoid the activity recreation after orientation changes so your activity will be more responsive on orientation changes.

like image 64
Dinesh Anuruddha Avatar answered Sep 20 '26 08:09

Dinesh Anuruddha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!