InputMethodInfo.javaAPI DocAndroid 1.5 API9965Wed May 06 22:41:56 BST 2009android.view.inputmethod


public final class InputMethodInfo extends Object implements android.os.Parcelable
This class is used to specify meta information of an input method.

Fields Summary
static final String
The Service that implements this input method component.
final String
The unique string Id to identify the input method. This is generated from the input method component.
final String
The input method setting activity's name, used by the system settings to launch the setting activity of this input method.
final int
The resource in the input method's .apk that holds a boolean indicating whether it should be considered the default input method for this system. This is a resource ID instead of the final value so that it can change based on the configuration (in particular locale).
public static final Parcelable.Creator
Used to make this class parcelable.
Constructors Summary
public InputMethodInfo(android.content.Context context, service)

context The Context in which we are parsing the input method.
service The ResolveInfo returned from the package manager about this input method's component.

        mService = service;
        ServiceInfo si = service.serviceInfo;
        mId = new ComponentName(si.packageName,;
        PackageManager pm = context.getPackageManager();
        String settingsActivityComponent = null;
        int isDefaultResId = 0;
        XmlResourceParser parser = null;
        try {
            parser = si.loadXmlMetaData(pm, InputMethod.SERVICE_META_DATA);
            if (parser == null) {
                throw new XmlPullParserException("No "
                        + InputMethod.SERVICE_META_DATA + " meta-data");
            AttributeSet attrs = Xml.asAttributeSet(parser);
            int type;
            while (( != XmlPullParser.END_DOCUMENT
                    && type != XmlPullParser.START_TAG) {
            String nodeName = parser.getName();
            if (!"input-method".equals(nodeName)) {
                throw new XmlPullParserException(
                        "Meta-data does not start with input-method tag");
            TypedArray sa = context.getResources().obtainAttributes(attrs,
            settingsActivityComponent = sa.getString(
            isDefaultResId = sa.getResourceId(
          , 0);
        } finally {
            if (parser != null) parser.close();
        mSettingsActivityName = settingsActivityComponent;
        mIsDefaultResId = isDefaultResId;
InputMethodInfo(android.os.Parcel source)

        mId = source.readString();
        mSettingsActivityName = source.readString();
        mIsDefaultResId = source.readInt();
        mService = ResolveInfo.CREATOR.createFromParcel(source);
public InputMethodInfo(String packageName, String className, CharSequence label, String settingsActivity)
Temporary API for creating a built-in input method.

        ResolveInfo ri = new ResolveInfo();
        ServiceInfo si = new ServiceInfo();
        ApplicationInfo ai = new ApplicationInfo();
        ai.packageName = packageName;
        ai.enabled = true;
        si.applicationInfo = ai;
        si.enabled = true;
        si.packageName = packageName; = className;
        si.exported = true;
        si.nonLocalizedLabel = label;
        ri.serviceInfo = si;
        mService = ri;
        mId = new ComponentName(si.packageName,;
        mSettingsActivityName = settingsActivity;
        mIsDefaultResId = 0;
Methods Summary
public intdescribeContents()

        return 0;
public voiddump(android.util.Printer pw, java.lang.String prefix)

        pw.println(prefix + "mId=" + mId
                + " mSettingsActivityName=" + mSettingsActivityName);
        pw.println(prefix + "mIsDefaultResId=0x"
                + Integer.toHexString(mIsDefaultResId));
        pw.println(prefix + "Service:");
        mService.dump(pw, prefix + "  ");
public booleanequals(java.lang.Object o)
Used to test whether the given parameter object is an {@link InputMethodInfo} and its Id is the same to this one.

true if the given parameter object is an {@link InputMethodInfo} and its Id is the same to this one.

        if (o == this) return true;
        if (o == null) return false;

        if (!(o instanceof InputMethodInfo)) return false;

        InputMethodInfo obj = (InputMethodInfo) o;
        return mId.equals(obj.mId);
public android.content.ComponentNamegetComponent()
Return the component of the service that implements this input method.

        return new ComponentName(mService.serviceInfo.packageName,
public java.lang.StringgetId()
Return a unique ID for this input method. The ID is generated from the package and class name implementing the method.

        return mId;
public intgetIsDefaultResourceId()
Return the resource identifier of a resource inside of this input method's .apk that determines whether it should be considered a default input method for the system.

        return mIsDefaultResId;
public java.lang.StringgetPackageName()
Return the .apk package that implements this input method.

        return mService.serviceInfo.packageName;
Return the raw information about the Service implementing this input method. Do not modify the returned object.

        return mService.serviceInfo;
public java.lang.StringgetServiceName()
Return the class name of the service component that implements this input method.

public java.lang.StringgetSettingsActivity()
Return the class name of an activity that provides a settings UI for the input method. You can launch this activity be starting it with an {@link android.content.Intent} whose action is MAIN and with an explicit {@link android.content.ComponentName} composed of {@link #getPackageName} and the class name returned here.

A null will be returned if there is no settings activity associated with the input method.

        return mSettingsActivityName;
public pm)
Load the user-displayed icon for this input method.

pm Supply a PackageManager used to load the input method's resources.

        return mService.loadIcon(pm);
public java.lang.CharSequenceloadLabel( pm)
Load the user-displayed label for this input method.

pm Supply a PackageManager used to load the input method's resources.

        return mService.loadLabel(pm);
public java.lang.StringtoString()

        return "InputMethodMetaInfo{" + mId
                + ", settings: "
                + mSettingsActivityName + "}";
public voidwriteToParcel(android.os.Parcel dest, int flags)
Used to package this object into a {@link Parcel}.

dest The {@link Parcel} to be written.
flags The flags used for parceling.

        mService.writeToParcel(dest, flags);