I've seen a few other questions similar to this, but I still cant seem to get an answer.
What I would ideally like is to use the intent method as shown below to switch to another activity.
Here is my MainActivity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendCalc (View view){
Intent intent = new Intent (this, MainActivity.class);
startActivity(intent);
}
and this is my second activity: {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
}
and here is my xml file for the button.
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/createCalc"
android:onClick="sendCalc"
android:elevation="2dp" />
Also, I have added the second activity in the manifest file.
Thank you in advance for the help.