Android Bundle ‘getSerializable(String?): Serializable?’ is deprecated. Deprecated in Java

  Kiến thức lập trình

enter image description here

/**
 * Returns the value associated with the given key, or {@code null} if:
 * <ul>
 *     <li>No mapping of the desired type exists for the given key.
 *     <li>A {@code null} value is explicitly associated with the key.
 *     <li>The object is not of type {@code clazz}.
 * </ul>
 *
 * @param key   a String, or null
 * @param clazz The expected class of the returned type
 * @return a Serializable value, or null
 */
@Nullable
public <T extends Serializable> T getSerializable(@Nullable String key,
        @NonNull Class<T> clazz) {
    return super.getSerializable(key, requireNonNull(clazz));
}

“My question is how to use Bundle’s getSerializable method to retrieve collection objects.”

LEAVE A COMMENT