Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; public class Main { /** * whether activity is system application */ public static boolean isSystemApplication(Context context) { if (context == null) { return false; } return isSystemApplication(context, context.getPackageName()); } /** * whether packageName is system application */ public static boolean isSystemApplication(Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); if (packageManager == null || packageName == null || packageName.length() == 0) { return false; } try { ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0); return (app != null && (app.flags & ApplicationInfo.FLAG_SYSTEM) > 0); } catch (Exception e) { e.printStackTrace(); } return false; } }