Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Map;

import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class Main {
    private static Map<String, Object> sCommonBundle = new ConcurrentHashMap<String, Object>();

    /**
     * <pre>
     * Put an object to temporary bundle to transfer data between objects (typically between activities)
     * This method resolves inconvenience of {@link Intent} which does not allow to put any data into its extra.
     * </pre>
     */
    public static void putToCommonBundle(String key, Object value) {
        if (key != null) {
            sCommonBundle.put(key, value);
        }
    }

    /**
     * <pre>
     * Like {@link #putToCommonBundle(String, Object)} but does not require a key. The key is generated uniquely and returned.
     * </pre>
     */
    public static String putToCommonBundle(Object value) {
        String key = UUID.randomUUID().toString();
        sCommonBundle.put(key, value);
        return key;
    }
}