FileDocCategorySizeDatePackage
PrintServiceInfo.javaAPI DocAndroid 5.1 API9599Thu Mar 12 22:22:10 GMT 2015android.printservice

PrintServiceInfo

public final class PrintServiceInfo extends Object implements android.os.Parcelable
This class describes a {@link PrintService}. A print service knows how to communicate with one or more printers over one or more protocols and exposes printers for use by the applications via the platform print APIs.
see
PrintService
see
android.print.PrintManager
hide

Fields Summary
private static final String
LOG_TAG
private static final String
TAG_PRINT_SERVICE
private final String
mId
private final android.content.pm.ResolveInfo
mResolveInfo
private final String
mSettingsActivityName
private final String
mAddPrintersActivityName
private final String
mAdvancedPrintOptionsActivityName
public static final Parcelable.Creator
CREATOR
Constructors Summary
public PrintServiceInfo(android.os.Parcel parcel)
Creates a new instance.

hide


              
       
        mId = parcel.readString();
        mResolveInfo = parcel.readParcelable(null);
        mSettingsActivityName = parcel.readString();
        mAddPrintersActivityName = parcel.readString();
        mAdvancedPrintOptionsActivityName = parcel.readString();
    
public PrintServiceInfo(android.content.pm.ResolveInfo resolveInfo, String settingsActivityName, String addPrintersActivityName, String advancedPrintOptionsActivityName)
Creates a new instance.

param
resolveInfo The service resolve info.
param
settingsActivityName Optional settings activity name.
param
addPrintersActivityName Optional add printers activity name.
param
advancedPrintOptionsActivityName Optional advanced print options activity.

        mId = new ComponentName(resolveInfo.serviceInfo.packageName,
                resolveInfo.serviceInfo.name).flattenToString();
        mResolveInfo = resolveInfo;
        mSettingsActivityName = settingsActivityName;
        mAddPrintersActivityName = addPrintersActivityName;
        mAdvancedPrintOptionsActivityName = advancedPrintOptionsActivityName;
    
Methods Summary
public static android.printservice.PrintServiceInfocreate(android.content.pm.ResolveInfo resolveInfo, android.content.Context context)
Creates a new instance.

param
resolveInfo The service resolve info.
param
context Context for accessing resources.
throws
XmlPullParserException If a XML parsing error occurs.
throws
IOException If a I/O error occurs.

        String settingsActivityName = null;
        String addPrintersActivityName = null;
        String advancedPrintOptionsActivityName = null;

        XmlResourceParser parser = null;
        PackageManager packageManager = context.getPackageManager();
        parser = resolveInfo.serviceInfo.loadXmlMetaData(packageManager,
                PrintService.SERVICE_META_DATA);
        if (parser != null) {
            try {
                int type = 0;
                while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
                    type = parser.next();
                }

                String nodeName = parser.getName();
                if (!TAG_PRINT_SERVICE.equals(nodeName)) {
                    Log.e(LOG_TAG, "Ignoring meta-data that does not start with "
                            + TAG_PRINT_SERVICE + " tag");
                } else {
                    Resources resources = packageManager.getResourcesForApplication(
                            resolveInfo.serviceInfo.applicationInfo);
                    AttributeSet allAttributes = Xml.asAttributeSet(parser);
                    TypedArray attributes = resources.obtainAttributes(allAttributes,
                            com.android.internal.R.styleable.PrintService);

                    settingsActivityName = attributes.getString(
                            com.android.internal.R.styleable.PrintService_settingsActivity);

                    addPrintersActivityName = attributes.getString(
                            com.android.internal.R.styleable.PrintService_addPrintersActivity);

                    advancedPrintOptionsActivityName = attributes.getString(com.android.internal
                            .R.styleable.PrintService_advancedPrintOptionsActivity);

                    attributes.recycle();
                }
            } catch (IOException ioe) {
                Log.w(LOG_TAG, "Error reading meta-data:" + ioe);
            } catch (XmlPullParserException xppe) {
                Log.w(LOG_TAG, "Error reading meta-data:" + xppe);
            } catch (NameNotFoundException e) {
                Log.e(LOG_TAG, "Unable to load resources for: "
                        + resolveInfo.serviceInfo.packageName);
            } finally {
                if (parser != null) {
                    parser.close();
                }
            }
        }

        return new PrintServiceInfo(resolveInfo, settingsActivityName,
                addPrintersActivityName, advancedPrintOptionsActivityName);
    
public intdescribeContents()
{@inheritDoc}

        return 0;
    
public booleanequals(java.lang.Object obj)

        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        PrintServiceInfo other = (PrintServiceInfo) obj;
        if (mId == null) {
            if (other.mId != null) {
                return false;
            }
        } else if (!mId.equals(other.mId)) {
            return false;
        }
        return true;
    
public java.lang.StringgetAddPrintersActivityName()
The add printers activity name.

Statically set from {@link PrintService#SERVICE_META_DATA meta-data}.

return
The add printers activity name.

        return mAddPrintersActivityName;
    
public java.lang.StringgetAdvancedOptionsActivityName()
The advanced print options activity name.

Statically set from {@link PrintService#SERVICE_META_DATA meta-data}.

return
The advanced print options activity name.

        return mAdvancedPrintOptionsActivityName;
    
public java.lang.StringgetId()
The accessibility service id.

Generated by the system.

return
The id.

        return mId;
    
public android.content.pm.ResolveInfogetResolveInfo()
The service {@link ResolveInfo}.

return
The info.

        return mResolveInfo;
    
public java.lang.StringgetSettingsActivityName()
The settings activity name.

Statically set from {@link PrintService#SERVICE_META_DATA meta-data}.

return
The settings activity name.

        return mSettingsActivityName;
    
public inthashCode()

        return 31 + ((mId == null) ? 0 : mId.hashCode());
    
public java.lang.StringtoString()

        StringBuilder builder = new StringBuilder();
        builder.append("PrintServiceInfo{");
        builder.append("id=").append(mId);
        builder.append(", resolveInfo=").append(mResolveInfo);
        builder.append(", settingsActivityName=").append(mSettingsActivityName);
        builder.append(", addPrintersActivityName=").append(mAddPrintersActivityName);
        builder.append(", advancedPrintOptionsActivityName=")
                .append(mAdvancedPrintOptionsActivityName);
        builder.append("}");
        return builder.toString();
    
public voidwriteToParcel(android.os.Parcel parcel, int flagz)

        parcel.writeString(mId);
        parcel.writeParcelable(mResolveInfo, 0);
        parcel.writeString(mSettingsActivityName);
        parcel.writeString(mAddPrintersActivityName);
        parcel.writeString(mAdvancedPrintOptionsActivityName);