Java Code Examples for android.content.pm.PackageManager#getText()

The following examples show how to use android.content.pm.PackageManager#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WallpaperInfo.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Return a brief summary of this wallpaper's behavior.
 */
public CharSequence loadDescription(PackageManager pm) throws NotFoundException {
    String packageName = mService.resolvePackageName;
    ApplicationInfo applicationInfo = null;
    if (packageName == null) {
        packageName = mService.serviceInfo.packageName;
        applicationInfo = mService.serviceInfo.applicationInfo;
    }
    if (mService.serviceInfo.descriptionRes != 0) {
        return pm.getText(packageName, mService.serviceInfo.descriptionRes,
                applicationInfo);
        
    }
    if (mDescriptionResource <= 0) throw new NotFoundException();
    return pm.getText(packageName, mDescriptionResource,
            mService.serviceInfo.applicationInfo);
}
 
Example 2
Source File: DeviceAdminInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Load user-visible description associated with this device admin.
 *
 * @param pm Supply a PackageManager used to load the device admin's
 * resources.
 */
public CharSequence loadDescription(PackageManager pm) throws NotFoundException {
    if (mActivityInfo.descriptionRes != 0) {
        return pm.getText(mActivityInfo.packageName,
                mActivityInfo.descriptionRes, mActivityInfo.applicationInfo);
    }
    throw new NotFoundException();
}
 
Example 3
Source File: WallpaperInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Return a string indicating the author(s) of this wallpaper.
 */
public CharSequence loadAuthor(PackageManager pm) throws NotFoundException {
    if (mAuthorResource <= 0) throw new NotFoundException();
    String packageName = mService.resolvePackageName;
    ApplicationInfo applicationInfo = null;
    if (packageName == null) {
        packageName = mService.serviceInfo.packageName;
        applicationInfo = mService.serviceInfo.applicationInfo;
    }
    return pm.getText(packageName, mAuthorResource, applicationInfo);
}
 
Example 4
Source File: AccessibilityServiceInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * The localized summary of the accessibility service.
 * <p>
 *    <strong>Statically set from
 *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
 * </p>
 * @return The localized summary if available, and {@code null} if a summary
 * has not been provided.
 */
public CharSequence loadSummary(PackageManager packageManager) {
    if (mSummaryResId == 0) {
        return mNonLocalizedSummary;
    }
    ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
    CharSequence summary = packageManager.getText(serviceInfo.packageName,
            mSummaryResId, serviceInfo.applicationInfo);
    if (summary != null) {
        return summary.toString().trim();
    }
    return null;
}
 
Example 5
Source File: AccessibilityServiceInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * The localized description of the accessibility service.
 * <p>
 *    <strong>Statically set from
 *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
 * </p>
 * @return The localized description.
 */
public String loadDescription(PackageManager packageManager) {
    if (mDescriptionResId == 0) {
        return mNonLocalizedDescription;
    }
    ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
    CharSequence description = packageManager.getText(serviceInfo.packageName,
            mDescriptionResId, serviceInfo.applicationInfo);
    if (description != null) {
        return description.toString().trim();
    }
    return null;
}
 
Example 6
Source File: ContactAdderFragment.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
/**
 * @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.
		final String packageName = description.packageName;
		final PackageManager pm = getActivity().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);
		}
	}
}
 
Example 7
Source File: SpellCheckerInfo.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Load the user-displayed label for this spell checker.
 *
 * @param pm Supply a PackageManager used to load the spell checker's resources.
 */
public CharSequence loadLabel(PackageManager pm) {
    if (mLabel == 0 || pm == null) return "";
    return pm.getText(getPackageName(), mLabel, mService.serviceInfo.applicationInfo);
}