Android現在実行中のデスクトップlauncherパッケージ名を取得


/**
     *           ( :                ,     Null,          )
     */
    public static String getLauncherPackageName(Context context) {
        final Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        final ResolveInfo res = context.getPackageManager().resolveActivity(intent, 0);
        if (res.activityInfo == null) {
            // should not happen. A home is always installed, isn't it?
            return null;
        }
        if (res.activityInfo.packageName.equals("android")) {
            //          ,        ;     
            return null;
        } else {
            return res.activityInfo.packageName;
        }
    }