Safcode Institute by Sir Safder





  • Send data from one activity to another

    //Page 1
    	ed1 = (EditText) findViewById(R.id.email);
            ed2 = (EditText) findViewById(R.id.password);
            bt1 = (Button) findViewById(R.id.button);
    
            bt1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String email = ed1.getText().toString();
                    String pass = ed2.getText().toString();
    
                    if(email.equals("admin@gmail.com") && pass.equals("123"))
                    {
                        //Toast.makeText(MainActivity.this, "Successfully Login", Toast.LENGTH_SHORT).show();
                        Intent i = new Intent(MainActivity.this, MainPage.class);
                        i.putExtra("keyemail", email);
                        i.putExtra("keypass", pass);
                        startActivity(i);
                    }
                    else
                    {
                        Toast.makeText(MainActivity.this, "Invalid Id or Password", Toast.LENGTH_SHORT).show();
                    }
                }
            });
    
    
    //Page 2
    
    	Textview tx = (TextView) findViewById(R.id.textView2);
            Intent i = getIntent();
            String email = i.getStringExtra("keyemail");
            tx.setText("Welcome " + email);
    



  • You Can Also Watch Our Tutorial