FileDocCategorySizeDatePackage
WallpaperInfo.javaAPI DocAndroid 5.1 API10549Thu Mar 12 22:22:10 GMT 2015android.app

WallpaperInfo

public final class WallpaperInfo extends Object implements android.os.Parcelable
This class is used to specify meta information of a wallpaper service.

Fields Summary
static final String
TAG
final android.content.pm.ResolveInfo
mService
The Service that implements this wallpaper component.
final String
mSettingsActivityName
The wallpaper setting activity's name, to launch the setting activity of this wallpaper.
final int
mThumbnailResource
Resource identifier for this wallpaper's thumbnail image.
final int
mAuthorResource
Resource identifier for a string indicating the author of the wallpaper.
final int
mDescriptionResource
Resource identifier for a string containing a short description of the wallpaper.
public static final Parcelable.Creator
CREATOR
Used to make this class parcelable.
Constructors Summary
public WallpaperInfo(android.content.Context context, android.content.pm.ResolveInfo service)
Constructor.

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


                                   
        
               
        mService = service;
        ServiceInfo si = service.serviceInfo;
        
        PackageManager pm = context.getPackageManager();
        String settingsActivityComponent = null;
        int thumbnailRes = -1;
        int authorRes = -1;
        int descriptionRes = -1;
        
        XmlResourceParser parser = null;
        try {
            parser = si.loadXmlMetaData(pm, WallpaperService.SERVICE_META_DATA);
            if (parser == null) {
                throw new XmlPullParserException("No "
                        + WallpaperService.SERVICE_META_DATA + " meta-data");
            }
        
            Resources res = pm.getResourcesForApplication(si.applicationInfo);
            
            AttributeSet attrs = Xml.asAttributeSet(parser);
            
            int type;
            while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
                    && type != XmlPullParser.START_TAG) {
            }
            
            String nodeName = parser.getName();
            if (!"wallpaper".equals(nodeName)) {
                throw new XmlPullParserException(
                        "Meta-data does not start with wallpaper tag");
            }
            
            TypedArray sa = res.obtainAttributes(attrs,
                    com.android.internal.R.styleable.Wallpaper);
            settingsActivityComponent = sa.getString(
                    com.android.internal.R.styleable.Wallpaper_settingsActivity);
            
            thumbnailRes = sa.getResourceId(
                    com.android.internal.R.styleable.Wallpaper_thumbnail,
                    -1);
            authorRes = sa.getResourceId(
                    com.android.internal.R.styleable.Wallpaper_author,
                    -1);
            descriptionRes = sa.getResourceId(
                    com.android.internal.R.styleable.Wallpaper_description,
                    -1);

            sa.recycle();
        } catch (NameNotFoundException e) {
            throw new XmlPullParserException(
                    "Unable to create context for: " + si.packageName);
        } finally {
            if (parser != null) parser.close();
        }
        
        mSettingsActivityName = settingsActivityComponent;
        mThumbnailResource = thumbnailRes;
        mAuthorResource = authorRes;
        mDescriptionResource = descriptionRes;
    
WallpaperInfo(android.os.Parcel source)

        mSettingsActivityName = source.readString();
        mThumbnailResource = source.readInt();
        mAuthorResource = source.readInt();
        mDescriptionResource = source.readInt();
        mService = ResolveInfo.CREATOR.createFromParcel(source);
    
Methods Summary
public intdescribeContents()


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

        pw.println(prefix + "Service:");
        mService.dump(pw, prefix + "  ");
        pw.println(prefix + "mSettingsActivityName=" + mSettingsActivityName);
    
public android.content.ComponentNamegetComponent()
Return the component of the service that implements this wallpaper.

        return new ComponentName(mService.serviceInfo.packageName,
                mService.serviceInfo.name);
    
public java.lang.StringgetPackageName()
Return the .apk package that implements this wallpaper.

        return mService.serviceInfo.packageName;
    
public android.content.pm.ServiceInfogetServiceInfo()
Return the raw information about the Service implementing this wallpaper. Do not modify the returned object.

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

        return mService.serviceInfo.name;
    
public java.lang.StringgetSettingsActivity()
Return the class name of an activity that provides a settings UI for the wallpaper. 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 wallpaper.

        return mSettingsActivityName;
    
public java.lang.CharSequenceloadAuthor(android.content.pm.PackageManager pm)
Return a string indicating the author(s) of this wallpaper.

        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);
    
public java.lang.CharSequenceloadDescription(android.content.pm.PackageManager pm)
Return a brief summary of this wallpaper's behavior.

        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);
    
public android.graphics.drawable.DrawableloadIcon(android.content.pm.PackageManager pm)
Load the user-displayed icon for this wallpaper.

param
pm Supply a PackageManager used to load the wallpaper's resources.

        return mService.loadIcon(pm);
    
public java.lang.CharSequenceloadLabel(android.content.pm.PackageManager pm)
Load the user-displayed label for this wallpaper.

param
pm Supply a PackageManager used to load the wallpaper's resources.

        return mService.loadLabel(pm);
    
public android.graphics.drawable.DrawableloadThumbnail(android.content.pm.PackageManager pm)
Load the thumbnail image for this wallpaper.

param
pm Supply a PackageManager used to load the wallpaper's resources.

        if (mThumbnailResource < 0) return null;

        return pm.getDrawable(mService.serviceInfo.packageName,
                              mThumbnailResource,
                              mService.serviceInfo.applicationInfo);
    
public java.lang.StringtoString()

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

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

        dest.writeString(mSettingsActivityName);
        dest.writeInt(mThumbnailResource);
        dest.writeInt(mAuthorResource);
        dest.writeInt(mDescriptionResource);
        mService.writeToParcel(dest, flags);