Show another Activity. - Android Activity

Android examples for Activity:Activity Start

Description

Show another Activity.

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;

public class Main {
    /** Show another Activity. */
    public static void show(@NonNull Context fromContext,
            @NonNull Class<? extends Activity> toActivity) {
        Intent intent = new Intent(fromContext, toActivity);
        if (!(fromContext instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }//from   w  w w.j av  a  2  s. c o m
        fromContext.startActivity(intent);
    }
}

Related Tutorials