start Activity by java package name - Android android.app

Android examples for android.app:Activity Start

Description

start Activity by java package name

Demo Code

import android.content.Context;
import android.content.Intent;

public class Main{

    public static void start(Context context) {
        try {/*from w  ww. j a  v a 2s.  c om*/
            Class clazz = Class
                    .forName("com.myapplication.SubActivity");
            Intent intent = new Intent(context, clazz);
            context.startActivity(intent);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

}

Related Tutorials