get Launch Activity Name - Android Activity

Android examples for Activity:Activity Title

Description

get Launch Activity Name

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import android.util.Log;

public class Main {
    private static final String tag = "BadgeUtil";

    private static String getLaunchActivityName(Context context) {
        PackageManager localPackageManager = context.getPackageManager();
        Intent localIntent = new Intent("android.intent.action.MAIN");
        localIntent.addCategory("android.intent.category.LAUNCHER");
        for (ResolveInfo localResolveInfo : localPackageManager
                .queryIntentActivities(localIntent, 0)) {
            if (!localResolveInfo.activityInfo.applicationInfo.packageName
                    .equalsIgnoreCase(context.getPackageName())) {
                continue;
            }// w ww  . j a v  a2  s . c  om
            return localResolveInfo.activityInfo.name;
        }
        return null;
    }
}

Related Tutorials