This example explain how to use an Intent for start a new Activity.
You need two activities:
In CurrentActivity you have to created an Intent. For that you have to specify two arguments:
Intent intent = new Intent(Context, DestinationActivity.class);
Then, call startActivity
passing the intent created.
startActivity(intent);
Now we have this source:
Intent intent = new Intent(this, DestinationActivity.class);
startActivity(intent);
For example, you can put it in a method an call it when an event ocurred.
void nextActivity(){
Intent intent = new Intent(this, DestinationActivity.class);
startActivity(intent);
}
public class CurrentActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.current_activity);
nextActivity();
finish(); // Finish current activity, if you don't finished it, the current activity will be in background. You can finish it then.
}
}