I have developed a application connect with wi-fi. In that app portrait/landscape transition restart the activity when rotate the phone and interrupt the socket connection. Then I add portrait to AndroidManifest.xml
file then problem have been solved. I want to know that is portrait/landscape transition effect to Async-Task also?
<activity
android:name="login"
android:label="@string/login_title"
android:configChanges="orientation|screenSize" >
</activity>
Login.java file
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class login extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
try{
Button buttonSignin = (Button) this.findViewById(R.id.btnSignIn);
//This is the place gives nullpointerException
buttonSignin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText user=(EditText) findViewById(R.id.txtUserName);
EditText pass=(EditText) findViewById(R.id.txtPassword);
if(user.getText().toString()== "")
{
return;
}
else if(pass.getText().toString()== "")
{
return;
}
else
{
LoginRequest reqs_login = new LoginRequest(login.this,login.this);
reqs_login.where="Login_Data";
reqs_login.title="Login";
reqs_login.username=user.getText().toString();
reqs_login.password=pass.getText().toString();
reqs_login.execute();
}
}
});
} catch (NullPointerException e) {
e.printStackTrace();
//Toast.makeText(getBaseContext(), "Error:1 on uplod file", Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
//Toast.makeText(getBaseContext(), "Error:2 File may be already exists", Toast.LENGTH_LONG).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
}