has Activity by package name and class name - Android Activity

Android examples for Activity:Activity Feature

Description

has Activity by package name and class name

Demo Code


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

public class Main {

    public static boolean hasActivity(Context context, String pkg,
            String cls) {//  ww  w  . j  a va 2  s  .  c  om
        boolean has = true;
        Intent intent = new Intent();
        intent.setClassName(pkg, cls);
        if (context.getPackageManager().resolveActivity(intent, 0) == null) {
            has = false;
        }
        return has;
    }
}

Related Tutorials