find Launcher Package Name - Android App

Android examples for App:Package

Description

find Launcher Package Name

Demo Code


//package com.java2s;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

public class Main {
    public static String findLauncherPackageName(
            PackageManager packageManager) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        ResolveInfo resolveInfo = packageManager.resolveActivity(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return resolveInfo.activityInfo.packageName;
    }/*from   w ww.  jav a  2  s  . c om*/
}

Related Tutorials