當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageManager.getText方法代碼示例

本文整理匯總了Java中android.content.pm.PackageManager.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java PackageManager.getText方法的具體用法?Java PackageManager.getText怎麽用?Java PackageManager.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.getText方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getData

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * 獲取Demo列表
 *
 * @return
 */
private List<Map<String, Object>> getData() {
    List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();

    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(CATEGORY_SAMPLE_CODE);

    PackageManager pm = getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);

    if (null == list)
        return myData;

    int len = list.size();

    for (int i = 0; i < len; i++) {
        ResolveInfo info = list.get(i);
        if (!getPackageName().equalsIgnoreCase(info.activityInfo.packageName)) {
            continue;
        }
        CharSequence labelSeq = info.loadLabel(pm);
        CharSequence description = null;
        if (info.activityInfo.descriptionRes != 0) {
            description = pm.getText(info.activityInfo.packageName,
                    info.activityInfo.descriptionRes, null);
        }

        String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name;
        addItem(myData,
                label,
                activityIntent(info.activityInfo.applicationInfo.packageName,
                        info.activityInfo.name), description);
    }
    return myData;
}
 
開發者ID:yangyankai,項目名稱:Seconds,代碼行數:40,代碼來源:ActivityMain.java

示例2: AccountData

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * @param name The name of the account. This is usually the user's email address or
 *        username.
 * @param description The description for this account. This will be dictated by the
 *        type of account returned, and can be obtained from the system AccountManager.
 */
public AccountData(String name, AuthenticatorDescription description) {
    mName = name;
    if (description != null) {
        mType = description.type;

        // The type string is stored in a resource, so we need to convert it into something
        // human readable.
        String packageName = description.packageName;
        PackageManager pm = getPackageManager();

        if (description.labelId != 0) {
            mTypeLabel = pm.getText(packageName, description.labelId, null);
            if (mTypeLabel == null) {
                throw new IllegalArgumentException("LabelID provided, but label not found");
            }
        } else {
            mTypeLabel = "";
        }

        if (description.iconId != 0) {
            mIcon = pm.getDrawable(packageName, description.iconId, null);
            if (mIcon == null) {
                throw new IllegalArgumentException("IconID provided, but drawable not " +
                        "found");
            }
        } else {
            mIcon = getResources().getDrawable(android.R.drawable.sym_def_app_icon);
        }
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:37,代碼來源:ContactAdder.java

示例3: loadText

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Load label
 *
 * @param packageName package name
 * @param labelId     label id
 * @return label
 */
static private String loadText(@NonNull final PackageManager packageManager, final String packageName, final int labelId)
{
	if (labelId != 0)
	{
		final CharSequence label = packageManager.getText(packageName, labelId, null);
		return label.toString();
	}
	return "?";
}
 
開發者ID:1313ou,項目名稱:Treebolic,代碼行數:17,代碼來源:Services.java


注:本文中的android.content.pm.PackageManager.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。