start Activity by class Path - Android Activity

Android examples for Activity:Activity Start

Description

start Activity by class Path

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;

public class Main {
    public static void start(Context context) {
        try {/*w ww . ja  va2 s. com*/
            Class clazz = Class
                    .forName("com.java2s.myapplication.SubActivity");
            Intent intent = new Intent(context, clazz);
            context.startActivity(intent);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials