diff --git a/src/de/robv/android/xposed/callbacks/XCallback.java b/src/de/robv/android/xposed/callbacks/XCallback.java index 50f004b0..4ef7645e 100644 --- a/src/de/robv/android/xposed/callbacks/XCallback.java +++ b/src/de/robv/android/xposed/callbacks/XCallback.java @@ -18,13 +18,7 @@ public XCallback(int priority) { public static class Param { public final TreeSet callbacks; - /** - * This can be used to store anything for the scope of the callback. - * Use this instead of instance variables. - * @see #getObjectExtra - * @see #setObjectExtra - */ - public final Bundle extra = new Bundle(); + private Bundle extra; protected Param() { callbacks = null; @@ -37,9 +31,21 @@ protected Param(TreeSet callbacks) { } } + /** + * This can be used to store anything for the scope of the callback. + * Use this instead of instance variables. + * @see #getObjectExtra + * @see #setObjectExtra + */ + public synchronized Bundle getExtra() { + if (extra == null) + extra = new Bundle(); + return extra; + } + /** @see #setObjectExtra */ public Object getObjectExtra(String key) { - Serializable o = extra.getSerializable(key); + Serializable o = getExtra().getSerializable(key); if (o instanceof SerializeWrapper) return ((SerializeWrapper) o).object; return null; @@ -47,7 +53,7 @@ public Object getObjectExtra(String key) { /** Provides a wrapper to store Objects in extra. */ public void setObjectExtra(String key, Object o) { - extra.putSerializable(key, new SerializeWrapper(o)); + getExtra().putSerializable(key, new SerializeWrapper(o)); } private static class SerializeWrapper implements Serializable {