Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -7286,6 +7286,8 @@ package android.content { ctor public ComponentName(android.os.Parcel); method public android.content.ComponentName clone(); method public int compareTo(android.content.ComponentName); method public static android.content.ComponentName createRelative(java.lang.String, java.lang.String); method public static android.content.ComponentName createRelative(android.content.Context, java.lang.String); method public int describeContents(); method public java.lang.String flattenToShortString(); method public java.lang.String flattenToString(); api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -7500,6 +7500,8 @@ package android.content { ctor public ComponentName(android.os.Parcel); method public android.content.ComponentName clone(); method public int compareTo(android.content.ComponentName); method public static android.content.ComponentName createRelative(java.lang.String, java.lang.String); method public static android.content.ComponentName createRelative(android.content.Context, java.lang.String); method public int describeContents(); method public java.lang.String flattenToShortString(); method public java.lang.String flattenToString(); core/java/android/content/ComponentName.java +51 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.content; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.io.PrintWriter; import java.lang.Comparable; Loading @@ -36,6 +37,56 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co private final String mPackage; private final String mClass; /** * Create a new component identifier where the class name may be specified * as either absolute or relative to the containing package. * * <p>Relative package names begin with a <code>'.'</code> character. For a package * <code>"com.example"</code> and class name <code>".app.MyActivity"</code> this method * will return a ComponentName with the package <code>"com.example"</code>and class name * <code>"com.example.app.MyActivity"</code>. Fully qualified class names are also * permitted.</p> * * @param pkg the name of the package the component exists in * @param cls the name of the class inside of <var>pkg</var> that implements * the component * @return the new ComponentName */ public static ComponentName createRelative(String pkg, String cls) { if (TextUtils.isEmpty(cls)) { throw new IllegalArgumentException("class name cannot be empty"); } final String fullName; if (cls.charAt(0) == '.') { // Relative to the package. Prepend the package name. fullName = pkg + cls; } else { // Fully qualified package name. fullName = cls; } return new ComponentName(pkg, fullName); } /** * Create a new component identifier where the class name may be specified * as either absolute or relative to the containing package. * * <p>Relative package names begin with a <code>'.'</code> character. For a package * <code>"com.example"</code> and class name <code>".app.MyActivity"</code> this method * will return a ComponentName with the package <code>"com.example"</code>and class name * <code>"com.example.app.MyActivity"</code>. Fully qualified class names are also * permitted.</p> * * @param pkg a Context for the package implementing the component * @param cls the name of the class inside of <var>pkg</var> that implements * the component * @return the new ComponentName */ public static ComponentName createRelative(Context pkg, String cls) { return createRelative(pkg.getPackageName(), cls); } /** * Create a new component identifier. * Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -7286,6 +7286,8 @@ package android.content { ctor public ComponentName(android.os.Parcel); method public android.content.ComponentName clone(); method public int compareTo(android.content.ComponentName); method public static android.content.ComponentName createRelative(java.lang.String, java.lang.String); method public static android.content.ComponentName createRelative(android.content.Context, java.lang.String); method public int describeContents(); method public java.lang.String flattenToShortString(); method public java.lang.String flattenToString();
api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -7500,6 +7500,8 @@ package android.content { ctor public ComponentName(android.os.Parcel); method public android.content.ComponentName clone(); method public int compareTo(android.content.ComponentName); method public static android.content.ComponentName createRelative(java.lang.String, java.lang.String); method public static android.content.ComponentName createRelative(android.content.Context, java.lang.String); method public int describeContents(); method public java.lang.String flattenToShortString(); method public java.lang.String flattenToString();
core/java/android/content/ComponentName.java +51 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.content; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.io.PrintWriter; import java.lang.Comparable; Loading @@ -36,6 +37,56 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co private final String mPackage; private final String mClass; /** * Create a new component identifier where the class name may be specified * as either absolute or relative to the containing package. * * <p>Relative package names begin with a <code>'.'</code> character. For a package * <code>"com.example"</code> and class name <code>".app.MyActivity"</code> this method * will return a ComponentName with the package <code>"com.example"</code>and class name * <code>"com.example.app.MyActivity"</code>. Fully qualified class names are also * permitted.</p> * * @param pkg the name of the package the component exists in * @param cls the name of the class inside of <var>pkg</var> that implements * the component * @return the new ComponentName */ public static ComponentName createRelative(String pkg, String cls) { if (TextUtils.isEmpty(cls)) { throw new IllegalArgumentException("class name cannot be empty"); } final String fullName; if (cls.charAt(0) == '.') { // Relative to the package. Prepend the package name. fullName = pkg + cls; } else { // Fully qualified package name. fullName = cls; } return new ComponentName(pkg, fullName); } /** * Create a new component identifier where the class name may be specified * as either absolute or relative to the containing package. * * <p>Relative package names begin with a <code>'.'</code> character. For a package * <code>"com.example"</code> and class name <code>".app.MyActivity"</code> this method * will return a ComponentName with the package <code>"com.example"</code>and class name * <code>"com.example.app.MyActivity"</code>. Fully qualified class names are also * permitted.</p> * * @param pkg a Context for the package implementing the component * @param cls the name of the class inside of <var>pkg</var> that implements * the component * @return the new ComponentName */ public static ComponentName createRelative(Context pkg, String cls) { return createRelative(pkg.getPackageName(), cls); } /** * Create a new component identifier. * Loading