You can do something like that in manifest to allow rotation:
<application
android:allowBackup="true"
android:configChanges="orientation|keyboardHidden|screenSize"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".activities.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"/>
Then you can catch the rotation with this snipet inside your activity:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.v(this.getClass().getName(), "onConfigurationChanged()");
}
To do an asynctask with progress dialog, this snipet should give you a ligth:
private ProgressDialog pDialog;
private class MyAsync extends AsyncTask<String, Void, String> {
Activity context;
public MyAsync (Activity context) {
this.context = context;
}
@Override
protected void onPreExecute(){
super.onPreExecute();
pdia = new ProgressDialog(context);
pdia.setMessage("Loading...");
pdia.show();
}
@Override
protected String doInBackground(String... urls) {
...
//do your login scheme
...
//context.methods()
return "ok";
}
@Override
protected void onPostExecute(String result) {
pDialog.dismiss();
if(result!=null && result.equals("ok")){
//login was successfully done
} else {
//login has failed
}
}
}
And to use this asynctask you shoud call:
new MyAsync(this).execute(null, null , null);
By the way this is your activity/fragment.