当前位置: 首页>>代码示例>>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;未经允许,请勿转载。