How to handle screen orientation changes when there is an asyntask running with android 4.x

Viewed 3493

I tried to implement the following code to handle screen orientation changes.

****DataBaseUpdateService.java****

public class DataBaseUpdateService extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 

        Updatetask Task = new Updatetask(this.getApplicationContext());
            if(Task.getStatus() == AsyncTask.Status.PENDING){
            Task.execute();};
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    @Override
    public void  onPause() {
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
    }
}

==========================================================================

****Androidmanifest.xml****
 <activity 
  android:name=".DataBaseUpdateService"
  android:configChanges="keyboardHidden|orientation"/>

Those codes work perfectly with android 3.x or lower. However, it does not work properly for android 4.x.

Do you have any idea what the problem is??

3 Answers
Related