Posts

Showing posts from 2017

#ChangePerspective

Image
Image indicates about Perspective ["a particular attitude towards or way of regarding something"]. In life sometimes your problem becomes a never ending rally so its good to take a detour i.e change the way you see your problem's its may help you in some ways to find solution to your problem.

#Healthy #thoughts

Image
" Chances flavors the prepared mind if that's chance appears go grab it "

#CodeSnippet - Get android system IP Address

//Create an instance of WifiManager (API for managing all aspects of Wi-Fi connectivity) WifiManager wifiManager= (WifiManager) getSystemService(WIFI_SERVICE); //and in case of fragments WifiManager wifiManager= (WifiManager) getActivity().getSystemService(WIFI_SERVICE); //Returns a string in the canonical IPv4 format String ipAddress = Formatter.formatIpAddress(wifiManager.getConnectionInfo().getIpAddress()); A warning says : "The method formatIpAddress(int) from the type Formatter is deprecated". This method was deprecated in API level 12. Use getHostAddress(), which supports both IPv4 and IPv6 addresses. This method does not support IPv6 addresses. as per android docs Android Docs So use formatIpAddress() because it works and add @SuppressWarnings("deprecation") to get rid of the warning. //Create an instance of WifiManager (API for managing all aspects of Wi-Fi connectivity) WifiManager wifiManager= (WifiManager) getSystemService(WIFI_SERVICE); //WifiI

#CodeSnippet - Reverse a byte array in android

Reverse a byte array using the following code public static void reverse(byte[] reverseArray) { // if array is empty return null if (reverseArray == null) { return; } //start index of array int i = 0; // get the length int j = reverseArray.length - 1; byte tmp; //for storing values for exchange purpose while (j > i) { tmp = array[j]; array[j] = array[i]; array[i] = tmp; j--; i++; } }