Answer the question
In order to leave comments, you need to log in
AsyncTask and screen rotation without android:configChanges, how to implement?
The main Activity has 2 fields - login and password, and a button. When the button is clicked, an AsyncTask is launched that performs authorization by showing the progress dialog to the user:
public AuthTask(Activity act) {
super();
this.activity = act;
}
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(activity);
dialog.setMessage("Авторизация...");
dialog.setIndeterminate(true);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
cancel(true);
}
});
dialog.setCancelable(true);
dialog.show();
}
@Override
protected void onPostExecute(User user) {
dialog.dismiss();
}
Answer the question
In order to leave comments, you need to log in
A simple solution could be to lock screen rotation before running AuthTask and unlock it after.
I don’t know if it’s suitable for your task: www.androiddesignpatterns.com/2013/04/retaining-ob... In a nutshell - async tasks are transferred to the headless fragment and from there the
onPostExecute (), onPreExecute () methods are updated with callbacks .d. implemented in MainActivity.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question