本文整理匯總了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;
}