Created
February 26, 2016 11:03
-
-
Save Kishanjvaghela/7c7dd582f3dadd22bfe7 to your computer and use it in GitHub Desktop.
Utility methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get android id of device. | |
* | |
* @param context app context | |
* @return android id | |
*/ | |
public static String getAndroidID(Context context) { | |
if (context != null) { | |
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); | |
} else { | |
return "N/A"; | |
} | |
} | |
/** | |
* get query parameter from url | |
* | |
* @param url url | |
* @return <key,value> pair of query parameter | |
*/ | |
public static Map<String, String> getQueryMap(String url) { | |
String[] params = url.split("&"); | |
Map<String, String> map = new HashMap<>(); | |
for (String param : params) { | |
String name = param.split("=")[0]; | |
String value = param.split("=")[1]; | |
map.put(name, value); | |
} | |
return map; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment