You can use one Activity to do both, like this:
public class MainActivity extends Activity {
/** Called when the activity is first created. */
static final int DATE_DIALOG_ID=0;
static final int DATE_DIALOG_IDD=1;
int yr,mon,day, yrr, monn, dayy;
Button btnLogin;
TextView lblStatus;
EditText txtUserName,txtPassword;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnLogin=(Button)findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(this);
lblStatus=(TextView)findViewById(R.id.lblStatus);
txtUserName=(EditText)findViewById(R.id.txtUserName);
txtPassword=(EditText)findViewById(R.id.txtPassword);
}
public void showDatePickerDialog(View v)
{
Calendar today=Calendar.getInstance();
yr=today.get(Calendar.YEAR);
mon=today.get(Calendar.MONTH);
day=today.get(Calendar.DAY_OF_MONTH);
showDialog(DATE_DIALOG_ID);
}
public void showDatePickerDialogg(View v)
{
Calendar today=Calendar.getInstance();
yrr=today.get(Calendar.YEAR);
monn=today.get(Calendar.MONTH);
dayy=today.get(Calendar.DAY_OF_MONTH);
showDialog(DATE_DIALOG_IDD);
}
protected Dialog onCreateDialog(int id)
{
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,dateSetListener,yr,mon+1,day);
case DATE_DIALOG_IDD:
return new DatePickerDialog(this,dateSetListenerr,yrr,monn+1,dayy);
}
return null;
}
private DatePickerDialog.OnDateSetListener dateSetListener=new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
yr=year;
mon=monthOfYear +1;
day=dayOfMonth;
EditText it=(EditText)findViewById(R.id.editText1);
it.setText(day+" - "+mon+" - "+yr);
}
};
private DatePickerDialog.OnDateSetListener dateSetListenerr=new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int yearr, int monthOfYearr,
int dayOfMonthh) {
// TODO Auto-generated method stub
yrr=yearr;
monn=monthOfYearr +1;
dayy=dayOfMonthh;
EditText itt=(EditText)findViewById(R.id.editText2);
itt.setText(dayy+" - "+monn+" - "+yrr);
}
};
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.btnLogin:
String userName=txtUserName.getText().toString();
String password=txtPassword.getText().toString();
if(verifyLogin(userName,password))
{
lblStatus.setText("Login Successful");
}
else
{
lblStatus.setText("Login Failed");
}
break;
}
}
public static String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
}
catch (IOException e) {
e.printStackTrace();
}
finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
public static boolean verifyLogin(String UserName,String Password)
{
try
{
System.out.println("guru");
DefaultHttpClient httpClient=new DefaultHttpClient();
//Connect to the server
HttpGet httpGet=new HttpGet("http://xxx/Service1.svc/checkLogin?name="+UserName+"&pass="+Password);
//Get the response
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream stream=httpEntity.getContent();
//Convert the stream to readable format
String result= convertStreamToString(stream);
if(result.charAt(1)=='1')
{
return true;
}
else
{
return false;
}
}
catch(Exception e)
{
return false;
}
}
}