try to Get Activity by Component Name - Android Activity

Android examples for Activity:Activity Start

Description

try to Get Activity by Component Name

Demo Code


//package com.java2s;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;

public class Main {
    public static ActivityInfo tryGetActivity(Context context,
            ComponentName componentName) {
        try {//from  w w  w .ja  v a2s.c  om
            return context.getPackageManager().getActivityInfo(
                    componentName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            return null;
        }
    }
}

Related Tutorials