This file contains hidden or 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
public static void wakeUpPhone(Context context, String tag) { | |
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); | |
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(( | |
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | | |
PowerManager.FULL_WAKE_LOCK | | |
PowerManager.ACQUIRE_CAUSES_WAKEUP), tag); | |
wakeLock.acquire(); | |
} |
This file contains hidden or 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
/** | |
* Removes all white spaces from string | |
* | |
* @param text - text to remove white spaces from | |
* @return - text without any whitespaces | |
*/ | |
public static String removeWhiteSpaces(String text) { | |
return text.replaceAll("\\s+", ""); | |
} |
This file contains hidden or 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
/** | |
* Check if the string contains a number or a special character | |
* | |
* @param text - string to check | |
* @return - true if it contains a number or a special character, else false | |
*/ | |
public boolean textContainsSpecialCharsOrNumbers(String text) { | |
return !text.matches("^[a-z A-Z]+$"); | |
} |
This file contains hidden or 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
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
String phoneNumber = telephonyManager.getLine1Number(); |
This file contains hidden or 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
public static void goToAppSettings(final Context context) { | |
final Uri uri = Uri.fromParts("package", context.getPackageName(), null); | |
final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, uri); | |
context.startActivity(intent); | |
} |
This file contains hidden or 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
/** | |
* Returns the current enabled/disabled status of the GPS provider. | |
* <p/> | |
* If the user has enabled GPS in the Settings menu, true | |
* is returned otherwise false is returned | |
*/ | |
public static boolean isGpsEnabled(final Context context) { | |
final LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
} |
This file contains hidden or 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
public static String getStringFromAssetFile(final Context context, final String filename) { | |
final int MAX_BUFF = 1024 * 100; | |
final InputStream is; | |
final InputStreamReader isr; | |
final BufferedReader br; | |
String resultData = ""; | |
try { | |
final AssetManager am = context.getAssets(); |
This file contains hidden or 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
final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); | |
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); |
This file contains hidden or 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
Generate KeyHash for Facebook SDK | |
1. First open a terminal (open a command prompt in windows). | |
2. Navigate in the terminal to the directory where your Android debug.keystore is stored. | |
3. Mostly it will located under “/Users/user_name/.android/” (In Windows will be C:\Documents and Settings\.android). | |
4. Once you are in the “.android” directory, run the following command.keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64 | |
Note: “androiddebugkey” can be the username for the keystone file and “debug.keystore” can be the name of the keynote file | |
1. When it prompts you for a password, type android and hit Enter |
This file contains hidden or 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
/usr/libexec/java_home |