當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。