the rght way to redirect no another in android studio code example

Example 1: go to activity android

//going to another activity while ending the 
//previous one so that users cannot go back
btListe = (ImageButton)findViewById(R.id.Button_Liste);
    btListe.setOnClickListener(new OnClickListener()
    {    public void onClick(View v)
        {
            intent = new Intent(main.this, ListViewImage.class);
            startActivity(intent);
            finish();
        }
    });

Example 2: intent jump to new activity

//Intent i = new Intent(getApplicationContext(), Second.class);
               // startActivity(i);

Tags:

Java Example