public class

RemoteViews

extends Object
implements Parcelable LayoutInflater.Filter
java.lang.Object
   ↳ android.widget.RemoteViews

Class Overview

A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.

Summary

Nested Classes
class RemoteViews.ActionException Exception to send when something goes wrong executing an action  
@interface RemoteViews.RemoteView This annotation indicates that a subclass of View is alllowed to be used with the RemoteViews mechanism. 
Constants
Creator<RemoteViews> CREATOR Parcelable.Creator that instantiates RemoteViews objects
[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Constructors
RemoteViews(String packageName, int layoutId)
Create a new RemoteViews object that will display the views contained in the specified layout file.
RemoteViews(Parcel parcel)
Reads a RemoteViews object from a parcel.
Public Methods
void addView(int viewId, RemoteViews nestedView)
Equivalent to calling addView(View) after inflating the given RemoteViews.
View apply(Context context, ViewGroup parent)
Inflates the view hierarchy represented by this object and applies all of the actions.
RemoteViews clone()
Creates and returns a copy of this Object.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
int getLayoutId()
String getPackage()
boolean onLoadClass(Class clazz)
Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.
void reapply(Context context, View v)
Applies all of the actions to the provided view.
void removeAllViews(int viewId)
Equivalent to calling removeAllViews().
void setBitmap(int viewId, String methodName, Bitmap value)
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
void setBoolean(int viewId, String methodName, boolean value)
Call a method taking one boolean on a view in the layout for this RemoteViews.
void setBundle(int viewId, String methodName, Bundle value)
Call a method taking one Bundle on a view in the layout for this RemoteViews.
void setByte(int viewId, String methodName, byte value)
Call a method taking one byte on a view in the layout for this RemoteViews.
void setChar(int viewId, String methodName, char value)
Call a method taking one char on a view in the layout for this RemoteViews.
void setCharSequence(int viewId, String methodName, CharSequence value)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
void setChronometer(int viewId, long base, String format, boolean started)
void setDouble(int viewId, String methodName, double value)
Call a method taking one double on a view in the layout for this RemoteViews.
void setFloat(int viewId, String methodName, float value)
Call a method taking one float on a view in the layout for this RemoteViews.
void setImageViewBitmap(int viewId, Bitmap bitmap)
Equivalent to calling ImageView.setImageBitmap
void setImageViewResource(int viewId, int srcId)
Equivalent to calling ImageView.setImageResource
void setImageViewUri(int viewId, Uri uri)
Equivalent to calling ImageView.setImageURI
void setInt(int viewId, String methodName, int value)
Call a method taking one int on a view in the layout for this RemoteViews.
void setLong(int viewId, String methodName, long value)
Call a method taking one long on a view in the layout for this RemoteViews.
void setOnClickPendingIntent(int viewId, PendingIntent pendingIntent)
Equivalent to calling setOnClickListener(android.view.View.OnClickListener) to launch the provided PendingIntent.
void setProgressBar(int viewId, int max, int progress, boolean indeterminate)
Equivalent to calling ProgressBar.setMax, ProgressBar.setProgress, and ProgressBar.setIndeterminate If indeterminate is true, then the values for max and progress are ignored.
void setShort(int viewId, String methodName, short value)
Call a method taking one short on a view in the layout for this RemoteViews.
void setString(int viewId, String methodName, String value)
Call a method taking one String on a view in the layout for this RemoteViews.
void setTextColor(int viewId, int color)
Equivalent to calling setTextColor(int).
void setTextViewText(int viewId, CharSequence text)
Equivalent to calling TextView.setText
void setUri(int viewId, String methodName, Uri value)
Call a method taking one Uri on a view in the layout for this RemoteViews.
void setViewVisibility(int viewId, int visibility)
Equivalent to calling View.setVisibility
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable
From interface android.view.LayoutInflater.Filter

Constants

public static final Creator<RemoteViews> CREATOR

Since: API Level 1

Parcelable.Creator that instantiates RemoteViews objects

Public Constructors

public RemoteViews (String packageName, int layoutId)

Since: API Level 1

Create a new RemoteViews object that will display the views contained in the specified layout file.

Parameters
packageName Name of the package that contains the layout resource
layoutId The id of the layout resource

public RemoteViews (Parcel parcel)

Since: API Level 1

Reads a RemoteViews object from a parcel.

Public Methods

public void addView (int viewId, RemoteViews nestedView)

Since: API Level 7

Equivalent to calling addView(View) after inflating the given RemoteViews. This allows users to build "nested" RemoteViews. In cases where consumers of RemoteViews may recycle layouts, use removeAllViews(int) to clear any existing children.

Parameters
viewId The id of the parent ViewGroup to add child into.
nestedView RemoteViews that describes the child.

public View apply (Context context, ViewGroup parent)

Since: API Level 1

Inflates the view hierarchy represented by this object and applies all of the actions.

Caller beware: this may throw

Parameters
context Default context to use
parent Parent that the resulting view hierarchy will be attached to. This method does not attach the hierarchy. The caller should do so when appropriate.
Returns
  • The inflated view hierarchy

public RemoteViews clone ()

Since: API Level 1

Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Returns
  • a copy of this object.

public int describeContents ()

Since: API Level 1

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public int getLayoutId ()

Since: API Level 1

public String getPackage ()

Since: API Level 1

public boolean onLoadClass (Class clazz)

Since: API Level 1

Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.

Parameters
clazz The class object for the View that is about to be inflated
Returns
  • True if this class is allowed to be inflated, or false otherwise

public void reapply (Context context, View v)

Since: API Level 1

Applies all of the actions to the provided view.

Caller beware: this may throw

Parameters
v The view to apply the actions to. This should be the result of the apply(Context, ViewGroup) call.

public void removeAllViews (int viewId)

Since: API Level 7

Equivalent to calling removeAllViews().

Parameters
viewId The id of the parent ViewGroup to remove all children from.

public void setBitmap (int viewId, String methodName, Bitmap value)

Since: API Level 3

Call a method taking one Bitmap on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setBoolean (int viewId, String methodName, boolean value)

Since: API Level 3

Call a method taking one boolean on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setBundle (int viewId, String methodName, Bundle value)

Since: API Level 8

Call a method taking one Bundle on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setByte (int viewId, String methodName, byte value)

Since: API Level 3

Call a method taking one byte on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setChar (int viewId, String methodName, char value)

Since: API Level 3

Call a method taking one char on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setCharSequence (int viewId, String methodName, CharSequence value)

Since: API Level 3

Call a method taking one CharSequence on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setChronometer (int viewId, long base, String format, boolean started)

Since: API Level 1
Parameters
viewId The id of the view whose text should change
base The time at which the timer would have read 0:00. This time should be based off of SystemClock.elapsedRealtime().
format The Chronometer format string, or null to simply display the timer value.
started True if you want the clock to be started, false if not.

public void setDouble (int viewId, String methodName, double value)

Since: API Level 3

Call a method taking one double on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setFloat (int viewId, String methodName, float value)

Since: API Level 3

Call a method taking one float on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setImageViewBitmap (int viewId, Bitmap bitmap)

Since: API Level 3

Equivalent to calling ImageView.setImageBitmap

Parameters
viewId The id of the view whose drawable should change
bitmap The new Bitmap for the drawable

public void setImageViewResource (int viewId, int srcId)

Since: API Level 1

Equivalent to calling ImageView.setImageResource

Parameters
viewId The id of the view whose drawable should change
srcId The new resource id for the drawable

public void setImageViewUri (int viewId, Uri uri)

Since: API Level 1

Equivalent to calling ImageView.setImageURI

Parameters
viewId The id of the view whose drawable should change
uri The Uri for the image

public void setInt (int viewId, String methodName, int value)

Since: API Level 3

Call a method taking one int on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setLong (int viewId, String methodName, long value)

Since: API Level 3

Call a method taking one long on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setOnClickPendingIntent (int viewId, PendingIntent pendingIntent)

Since: API Level 3

Equivalent to calling setOnClickListener(android.view.View.OnClickListener) to launch the provided PendingIntent.

Parameters
viewId The id of the view that will trigger the PendingIntent when clicked
pendingIntent The PendingIntent to send when user clicks

public void setProgressBar (int viewId, int max, int progress, boolean indeterminate)

Since: API Level 1

Equivalent to calling ProgressBar.setMax, ProgressBar.setProgress, and ProgressBar.setIndeterminate If indeterminate is true, then the values for max and progress are ignored.

Parameters
viewId The id of the view whose text should change
max The 100% value for the progress bar
progress The current value of the progress bar.
indeterminate True if the progress bar is indeterminate, false if not.

public void setShort (int viewId, String methodName, short value)

Since: API Level 3

Call a method taking one short on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setString (int viewId, String methodName, String value)

Since: API Level 3

Call a method taking one String on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setTextColor (int viewId, int color)

Since: API Level 3

Equivalent to calling setTextColor(int).

Parameters
viewId The id of the view whose text should change
color Sets the text color for all the states (normal, selected, focused) to be this color.

public void setTextViewText (int viewId, CharSequence text)

Since: API Level 1

Equivalent to calling TextView.setText

Parameters
viewId The id of the view whose text should change
text The new text for the view

public void setUri (int viewId, String methodName, Uri value)

Since: API Level 3

Call a method taking one Uri on a view in the layout for this RemoteViews.

Parameters
viewId The id of the view whose text should change
methodName The name of the method to call.
value The value to pass to the method.

public void setViewVisibility (int viewId, int visibility)

Since: API Level 1

Equivalent to calling View.setVisibility

Parameters
viewId The id of the view whose visibility should change
visibility The new visibility for the view

public void writeToParcel (Parcel dest, int flags)

Since: API Level 1

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.