Android examples for android.media:Volume
get Volume Size
import android.content.Context; import java.math.BigInteger; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String getVolume(long volume) { float num = 1.0F; String str = null;/* w w w .java2 s . com*/ if (volume < 1024) { str = volume + "B"; } else if (volume < 1048576) { num = num * volume / 1024; str = format("%.1f", num) + "K"; } else if (volume < 1073741824) { num = num * volume / 1048576; str = format("%.1f", num) + "M"; } else if (volume < 1099511627776L) { num = num * volume / 1073741824; str = format("%.1f", num) + "G"; } return str; } }