Sandesh Patil Sandesh Patil - 4 months ago 9
Java Question

was trying for intent class to swap to new page in android but its not going to next page

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.content.Intent;

import android.util.Log;

import android.view.Menu;

import android.view.View;

import android.widget.Button;


public class MainActivity extends AppCompatActivity {

Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, SecondPage.class);
MainActivity.this.startActivities(i);

}

});


}

private void startActivities(Intent i) {
}

}

Answer

Just replace MainActivity.this.startActivities(i); to startActivity(i);.