start Activity various means - Android Activity

Android examples for Activity:Activity Start

Description

start Activity various means

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class Main {
    public static void startActivity(Context context,
            Class<? extends Activity> toklass) {
        Intent intent = new Intent(context, toklass);
        context.startActivity(intent);//from   ww w.jav a  2s.  c o m
    }

    public static void startActivity(Context context, Intent intent,
            Bundle extras) {
        intent.putExtras(extras);
        context.startActivity(intent);
    }

    public static void startActivity(Context context,
            Class<? extends Activity> toklass, Bundle extras) {
        Intent intent = new Intent(context, toklass);
        intent.putExtras(extras);
        context.startActivity(intent);
    }

    public static void startActivity(Activity fromActivity,
            Class<? extends Activity> toklass, Bundle extras,
            int enterAnim, int exitAnim) {
        Intent intent = new Intent(fromActivity, toklass);
        intent.putExtras(extras);
        fromActivity.startActivity(intent);
        fromActivity.overridePendingTransition(enterAnim, exitAnim);
    }
}

Related Tutorials