Java Code Examples for android.content.pm.PackageManager.getServiceInfo()

The following are Jave code examples for showing how to use getServiceInfo() of the android.content.pm.PackageManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lineagex86   File: SoundSettings.java   View Source Code Vote up 6 votes
private String getSuppressorCaption(ComponentName suppressor) {
    final PackageManager pm = mContext.getPackageManager();
    try {
        final ServiceInfo info = pm.getServiceInfo(suppressor, 0);
        if (info != null) {
            final CharSequence seq = info.loadLabel(pm);
            if (seq != null) {
                final String str = seq.toString().trim();
                if (str.length() > 0) {
                    return str;
                }
            }
        }
    } catch (Throwable e) {
        Log.w(TAG, "Error loading suppressor caption", e);
    }
    return suppressor.getPackageName();
}
 
Example 2
Project: AI-Powered-Intelligent-Banking-Platform   File: RecognitionServiceManager.java   View Source Code Vote up 6 votes
public static Pair<String, String> getLabel(Context context, String comboAsString) {
    String recognizer = "[?]";
    String language = "[?]";
    String[] splits = TextUtils.split(comboAsString, SEPARATOR);
    if (splits.length > 0) {
        PackageManager pm = context.getPackageManager();
        ComponentName recognizerComponentName = ComponentName.unflattenFromString(splits[0]);
        if (recognizerComponentName != null) {
            try {
                ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
                recognizer = si.loadLabel(pm).toString();
            } catch (PackageManager.NameNotFoundException e) {
                // ignored
            }
        }
    }
    if (splits.length > 1) {
        language = makeLangLabel(splits[1]);
    }
    return new Pair<>(recognizer, language);
}
 
Example 3
Project: AI-Powered-Intelligent-Banking-Platform   File: RecognitionServiceManager.java   View Source Code Vote up 6 votes
public static Pair<String, String> getLabel(Context context, String comboAsString) {
    String recognizer = "[?]";
    String language = "[?]";
    String[] splits = TextUtils.split(comboAsString, SEPARATOR);
    if (splits.length > 0) {
        PackageManager pm = context.getPackageManager();
        ComponentName recognizerComponentName = ComponentName.unflattenFromString(splits[0]);
        if (recognizerComponentName != null) {
            try {
                ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
                recognizer = si.loadLabel(pm).toString();
            } catch (PackageManager.NameNotFoundException e) {
                // ignored
            }
        }
    }
    if (splits.length > 1) {
        language = makeLangLabel(splits[1]);
    }
    return new Pair<>(recognizer, language);
}
 
Example 4
Project: GitHub   File: TinkerServiceInternals.java   View Source Code Vote up 5 votes
private static String getServiceProcessName(Context context, Class<? extends Service> serviceClass) {
    PackageManager packageManager = context.getPackageManager();

    ComponentName component = new ComponentName(context, serviceClass);
    ServiceInfo serviceInfo;
    try {
        serviceInfo = packageManager.getServiceInfo(component, 0);
    } catch (Throwable ignored) {
        // Service is disabled.
        return null;
    }

    return serviceInfo.processName;
}
 
Example 5
Project: AI-Powered-Intelligent-Banking-Platform   File: RecognitionServiceManager.java   View Source Code Vote up 5 votes
public static String getServiceLabel(Context context, ComponentName recognizerComponentName) {
    String recognizer = "[?]";
    PackageManager pm = context.getPackageManager();
    if (recognizerComponentName != null) {
        try {
            ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
            recognizer = si.loadLabel(pm).toString();
        } catch (PackageManager.NameNotFoundException e) {
            // ignored
        }
    }
    return recognizer;
}
 
Example 6
Project: AI-Powered-Intelligent-Banking-Platform   File: RecognitionServiceManager.java   View Source Code Vote up 5 votes
public static String getServiceLabel(Context context, ComponentName recognizerComponentName) {
    String recognizer = "[?]";
    PackageManager pm = context.getPackageManager();
    if (recognizerComponentName != null) {
        try {
            ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
            recognizer = si.loadLabel(pm).toString();
        } catch (PackageManager.NameNotFoundException e) {
            // ignored
        }
    }
    return recognizer;
}