How to switch between Activities in Android

To switch Menus/Activities in Android App
public void backToMainMenu(View view){ 
	Intent i = new Intent(getApplicationContext(), PreviousMenuClassName.class);
  1. I called this function in XML file as android:onClick=”backToMainMenu” in the attributes of button.
  2. The function must be public and have only one attribute i.e. “View view”
  3. You can call “i” whatever you wish.
  4. “PreviousMenuClassName” is the name of the Activity where you want to go after clicking the button.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: