0

this is the emulator

This profile button goes to the next activity, but when I click it; it clicks but doesn't open the next activity. I want to know why it doesn't go to the next activity. //this is the code I have put the NullPointerException because it used to always show up in the logcat that I have an IllegalNullPointerException on that line.

public class MainActivity extends AppCompatActivity {

 ImageButton profile;
@Override
protected void onCreate(Bundle savedInstanceState) {


    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  
   profile= findViewById(R.id.imageButton2);

    profile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = null;
            try{
                i=new Intent(context, DetailsActivity.class);
                context.startActivity(i);
            }
            catch(NullPointerException ignored){
            }

        }
    });

0 Answers0