Android Activity Get getFirstActivityName(Context context, String pkg)

Here you can find the source of getFirstActivityName(Context context, String pkg)

Description

get First Activity Name

License

Open Source License

Declaration

public static String getFirstActivityName(Context context, String pkg) 

Method Source Code

//package com.java2s;

import java.util.List;

import android.content.Context;

import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import android.util.Log;

public class Main {

    public static String getFirstActivityName(Context context, String pkg) {
        String activityName = null;

        List<PackageInfo> list = context.getPackageManager()
                .getInstalledPackages(PackageManager.GET_ACTIVITIES);

        int length = list.size();
        Log.d("pkg length", length + "");

        for (int i = 0; i < length; i++) {
            String name = list.get(i).packageName;
            Log.d("pkg " + i, name);

            if (name.equalsIgnoreCase(pkg)) {
                ActivityInfo activityinfo = list.get(i).activities[0];
                activityName = activityinfo.name;
                Log.d("activity " + i, activityName);
                break;
            }/*from  w w  w  .  j a  v a  2 s . c om*/
        }

        return activityName;
    }
}

Related

  1. provideNavigationAdapter( Activity activity, String[] items)
  2. getThemeUpIndicator(Object info, Activity activity)
  3. getThemeUpIndicator(Object info, Activity activity)
  4. getActivityMetaData(Activity activity, String key)
  5. isSingleFragmentIntent(Activity activity)