Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Thursday, 18 October 2012

Create and Login application as above . On successful login , open browser with any URL.

Pro4Activity.java
package ps.pro4;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Pro4Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Button btlogin,btclear;
 EditText editemail,editpass;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        editemail=(EditText) findViewById(R.id.editemail);
        editpass=(EditText) findViewById(R.id.editpass);
        btlogin=(Button) findViewById(R.id.btlogin);
        btclear=(Button) findViewById(R.id.btclear);
        btlogin.setOnClickListener(this);
        btclear.setOnClickListener(this);
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  Button action=(Button) v;
  if(action.getId()==btlogin.getId())
  {
   String email=editemail.getText().toString();
   String pass=editpass.getText().toString();
   
   if(email.equals("pankaj@gmail.com") && pass.equals("pankaj"))
   {
    Intent myintent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.gmail.com"));
    this.startActivity(myintent);
   }
   else
   {
    Toast.makeText(this,"Sorry", Toast.LENGTH_SHORT).show();
   }
   
  }
  else if(action.getId()==btclear.getId())
  {
   if(!editemail.getText().toString().equals("") ||  !editpass.getText().toString().equals(""))
   {
    editemail.setText("");
    editpass.setText("");
   }
   else
   {
    Toast.makeText(this,"Already Cleared...", Toast.LENGTH_SHORT).show();
   }
  }
 }
}

No comments:

Post a Comment