Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import java.util.TreeMap; import android.os.Bundle; public class Main { private static Bundle createNamePortBundle(String name, int port, TreeMap<String, ArrayList<String>> ips) { Bundle namePort = new Bundle(); namePort.putString("name", name); namePort.putInt("port", port); if (ips != null) { ArrayList<String> ip = ips.get(name); Collections.shuffle(ip, new Random()); namePort.putString("ip", ip.get(0)); } return namePort; } }