当前位置: 首页>>代码示例>>Java>>正文


Java PackageManager.getServiceInfo方法代码示例

本文整理汇总了Java中android.content.pm.PackageManager.getServiceInfo方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.getServiceInfo方法的具体用法?Java PackageManager.getServiceInfo怎么用?Java PackageManager.getServiceInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.getServiceInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSuppressorCaption

import android.content.pm.PackageManager; //导入方法依赖的package包/类
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();
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:19,代码来源:SoundSettings.java

示例2: getLabel

import android.content.pm.PackageManager; //导入方法依赖的package包/类
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);
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:22,代码来源:RecognitionServiceManager.java

示例3: getServiceProcessName

import android.content.pm.PackageManager; //导入方法依赖的package包/类
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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:TinkerServiceInternals.java

示例4: getServiceLabel

import android.content.pm.PackageManager; //导入方法依赖的package包/类
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;
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:14,代码来源:RecognitionServiceManager.java


注:本文中的android.content.pm.PackageManager.getServiceInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。