本文整理汇总了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();
}
示例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;
}
示例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