Skip to content

Instantly share code, notes, and snippets.

View xalexchen's full-sized avatar
🤖

Alex.Chen xalexchen

🤖
View GitHub Profile
@xalexchen
xalexchen / Util.java
Last active December 22, 2015 08:59
safety use implicit intent
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
@xalexchen
xalexchen / preferences.xml
Created August 30, 2013 08:48
perform a action to start an activity on preference xml file
<PreferenceScreen
android:title="@string/system_info"
android:summary="@string/system_info_summary">
<intent android:action=".ui.SystemInfo" />
</PreferenceScreen>
@xalexchen
xalexchen / SDUtil.java
Last active September 30, 2017 20:43
Android: Finding the SD Card Path “In devices with multiple ‘external’ storage directories (such as both secure app storage and mountable shared storage), this directory represents the ‘primary’ external storage that the user will interact with.” replace method Environment.getExternalStoreDirectory()
File file = new File("/system/etc/vold.fstab");
FileReader fr = null;
BufferedReader br = null;
try {
fr = new FileReader(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
@xalexchen
xalexchen / changelocale
Created December 13, 2012 06:32
when we want to change android system default language on our own application,we can use java reflection mechanism to invoke android non public methods
updateLanguage(Locale.SIMPLIFIED_CHINESE);
updateLanguage(Locale.ENGLISH);
..
..
..
..
private void updateLanguage(Locale locale) {
Log.d("ANDROID_LAB", locale.toString());