Utils

public class Utils

Methods

bytesToHex

public static String bytesToHex(byte[] bytes)

Convert byte array to hex string

Parameters:
  • bytes

copyAssets

static void copyAssets(Context ctx)

getIPAddress

public static String getIPAddress(boolean useIPv4)

Get IP address from first non-localhost interface

Parameters:
  • ipv4 – true=return ipv4, false=return ipv6
Returns:

address or empty string

getMACAddress

public static String getMACAddress(String interfaceName)

Returns MAC address of the given interface name.

Parameters:
  • interfaceName – eth0, wlan0 or NULL=use first interface
Returns:

mac address or empty string

getResourcePathByAssetCopy

public static String getResourcePathByAssetCopy(Context ctx, String assetSubFolder, String fileToCopy)

Copy the specified resource file from the assets folder into the “files dir” of this application, so that this resource can be opened by the Voip Lib by providing it the absolute path of the copied resource

Parameters:
  • ctx – The application context
  • assetPath – The path of the resource (e.g on_hold.wav or sounds/on_hold.wav)
Returns:

the absolute path of the copied resource, or null if no file was copied.

getUTF8Bytes

public static byte[] getUTF8Bytes(String str)

Get utf8 byte array.

Parameters:
  • str
Returns:

array of NULL if error was found

loadFileAsString

public static String loadFileAsString(String filename)

Load UTF8withBOM or any ansi text file.

Parameters:
  • filename
Throws: