本文整理汇总了Java中android.content.pm.ActivityInfo.loadLabel方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityInfo.loadLabel方法的具体用法?Java ActivityInfo.loadLabel怎么用?Java ActivityInfo.loadLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.ActivityInfo
的用法示例。
在下文中一共展示了ActivityInfo.loadLabel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableThemes
import android.content.pm.ActivityInfo; //导入方法依赖的package包/类
public static HashMap<String, String> getAvailableThemes(Context ctxt){
HashMap<String, String> result = new HashMap<String, String>();
result.put("", ctxt.getResources().getString(R.string.app_name));
PackageManager packageManager = ctxt.getPackageManager();
Intent it = new Intent(SipManager.ACTION_GET_DRAWABLES);
List<ResolveInfo> availables = packageManager.queryBroadcastReceivers(it, 0);
Log.d(THIS_FILE, "We found " + availables.size() + "themes");
for(ResolveInfo resInfo : availables) {
Log.d(THIS_FILE, "We have -- "+resInfo);
ActivityInfo actInfos = resInfo.activityInfo;
ComponentName cmp = new ComponentName(actInfos.packageName, actInfos.name);
String label = (String) actInfos.loadLabel(packageManager);
if(TextUtils.isEmpty(label)) {
label = (String) resInfo.loadLabel(packageManager);
}
result.put(cmp.flattenToString(), label);
}
return result;
}
示例2: getApplicationInfo
import android.content.pm.ActivityInfo; //导入方法依赖的package包/类
private static ApplicationInfo getApplicationInfo(PackageManager manager, Intent intent) {
final ResolveInfo resolveInfo = manager.resolveActivity(intent, 0);
if (resolveInfo == null) {
return null;
}
final ApplicationInfo info = new ApplicationInfo();
final ActivityInfo activityInfo = resolveInfo.activityInfo;
info.icon = activityInfo.loadIcon(manager);
if (info.title == null || info.title.length() == 0) {
info.title = activityInfo.loadLabel(manager);
}
if (info.title == null) {
info.title = "";
}
return info;
}
示例3: ensureValidName
import android.content.pm.ActivityInfo; //导入方法依赖的package包/类
/**
* Ensures that we have a valid, non-null name. If the provided name is null, we will return
* the application name instead.
*/
@Thunk static CharSequence ensureValidName(Context context, Intent intent, CharSequence name) {
if (name == null) {
try {
PackageManager pm = context.getPackageManager();
ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0);
name = info.loadLabel(pm);
} catch (PackageManager.NameNotFoundException nnfe) {
return "";
}
}
return name;
}
示例4: doInBackground
import android.content.pm.ActivityInfo; //导入方法依赖的package包/类
@Override
protected Void doInBackground(DonateActivity.DonateItem... params) {
Context context = mReference.get();
if (context != null) {
PackageManager packageManager = context.getPackageManager();
for (DonateActivity.DonateItem item : params) {
ActivityInfo ai = packageManager.resolveActivity(item.intent, 0).activityInfo;
item.label = ai.loadLabel(packageManager);
item.icon = ai.loadIcon(packageManager);
this.publishProgress(item);
}
}
return null;
}