android enthusiast
android enthusiast

Reputation: 2092

How to override/ modify a value or method from the sdk?

I would like to modify the value of a int in the Notification.class in the SDK. Is this possible? Can this be achieved ? This is the int I'd like to modify, override:

public class Notification implements Parcelable {
.......
    /**
 * Maximum length of CharSequences accepted by Builder and friends.
 *
 * <p>
 * Avoids spamming the system with overly large strings such as full e-mails.
 */
private static final int MAX_CHARSEQUENCE_LENGTH = 10 * 1024;

/**

... or alternatively, I'd like to override this method from the same class:

    /**
 * Make sure this CharSequence is safe to put into a bundle, which basically
 * means it had better not be some custom Parcelable implementation.
 * @hide
 */
public static CharSequence safeCharSequence(CharSequence cs) {
    if (cs == null) return cs;
    if (cs.length() > MAX_CHARSEQUENCE_LENGTH) {

        cs = cs.subSequence(0, MAX_CHARSEQUENCE_LENGTH);
    }
    if (cs instanceof Parcelable) {
        Log.e(TAG, "warning: " + cs.getClass().getCanonicalName()
                + " instance is a custom Parcelable and not allowed in Notification");
        return cs.toString();
    }
    return removeTextSizeSpans(cs);
}

Upvotes: 1

Views: 136

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006819

Is this possible?

In your own custom ROM? Yes.

In an Android app? No. More accurately, you have no means of affecting safeCharSequence() from your app, except perhaps on a rooted device.

Upvotes: 2

Related Questions