postheadericon implicit intent in android example


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


File Name : E4Activity.java


package bsr.exa;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class E4Activity extends Activity {
/** @author Bipin S Rupadiya , www.gtu-android.blogspot.com
     *
     *  3) Create login application where you will have to validate EmailID(UserName).
     *     Till the user name and password is not validated , login button should remain disabled.
     *  
     *  4) Create and Login application as above . On successful login , open browser with any URL.
     *  
     **/
String uname="rupadiyabipin@gmail.com";
String pwd="bipin";

boolean usrStatus=false;
boolean pwdStatus=false;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final Button cmdLogin = (Button) findViewById(R.id.cmdLogin);
        final EditText txtUsr = (EditText)findViewById(R.id.txtUsr);
        final EditText txtPwd = (EditText)findViewById(R.id.txtPwd);

     
        cmdLogin.setEnabled(false);
        cmdLogin.setOnClickListener(new Button.OnClickListener()
        {
        @Override
        public void onClick(View v)
        {
        EditText fldu=(EditText)findViewById(R.id.txtUsr);
        EditText fldp=(EditText)findViewById(R.id.txtPwd);
        String un= fldu.getText().toString();
       
        if((fldu.getText().toString().equals(uname))&&(fldp.getText().toString().equals(pwd)))
        {  
        Uri myUri=Uri.parse("http://BipinRupadiya.blogspot.com");
        Intent intent=new Intent(Intent.ACTION_VIEW,myUri);
        startActivity(intent);
        }
        else
        {
        Toast.makeText(E4Activity.this, "sorry  ".concat(un).toString().concat(" you are unauthenticated user!  "), Toast.LENGTH_LONG).show();
        }
        }      
        });
        //------------------------------------------------
        //clear event
       final Button btnClear = (Button)findViewById(R.id.cmdClear);
       btnClear.setOnClickListener(new Button.OnClickListener()
        {
        @Override
        public void onClick(View v)
        {
        EditText fldu=(EditText)findViewById(R.id.txtUsr);
        EditText fldp=(EditText)findViewById(R.id.txtPwd);
        fldu.setText("");
        fldp.setText("");        
        }      
        });
     
        //------------------------------------------------

        txtUsr.addTextChangedListener(new TextWatcher()
        {

@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
if(uname.equals(txtUsr.getText().toString()))
{
usrStatus=true;
}
else
{
usrStatus=false;
}
}

@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
if(usrStatus && pwdStatus)
{
cmdLogin.setEnabled(true);
}
else
{
cmdLogin.setEnabled(false);
}

}
});
     
        txtPwd.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub

if(pwd.equals(txtPwd.getText().toString()))
{
pwdStatus=true;
}
else
{
pwdStatus=false;
}
}

@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub

if(usrStatus && pwdStatus)
{
cmdLogin.setEnabled(true);
}
else
{
cmdLogin.setEnabled(false);
}
}
});
    }
 

}

Follow by Email

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.