如何从sdk覆盖/修改值或方法?

时间:2018-03-20 21:15:44

标签: android mobile overrides

我想修改SDK中Notification.class中int的值。这可能吗?这可以实现吗?  这是我要修改的int,覆盖:

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;

/**

... 或者,我想从同一个类重写此方法:

    /**
 * 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);
}

1 个答案:

答案 0 :(得分:2)

  

这可能吗?

在您自己的自定义ROM中?是。

在Android应用中?不可以。更准确地说,除了根设备之外,您无法从应用中影响safeCharSequence()