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
| // Usage: | |
| // blacklist | |
| String[] blacklist = new String[]{"com.any.package", "net.other.package"}; | |
| // your share intent | |
| Intent intent = new Intent(Intent.ACTION_SEND); | |
| intent.setType("text/plain"); | |
| intent.putExtra(Intent.EXTRA_TEXT, "some text"); | |
| intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject"); | |
| // ... anything else you want to add | |
| // invoke custom chooser |
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
| textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, unitTextSize); |
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
| git submodule foreach 'git checkout release_anjuke7.1 || :' | |
| Add '|| :' to avoid Stopping at a submodule; |
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
| /** | |
| * whether this process is named with processName | |
| * | |
| * @param processName | |
| * @return | |
| */ | |
| private static boolean isNamedProcess(Context context, String processName) { | |
| if (TextUtils.isEmpty(processName)) { | |
| return true; | |
| } |
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
| /** | |
| * get system install location<br/> | |
| * can be set by System Menu Setting->Storage->Prefered install location | |
| * | |
| * @return | |
| * @see {@link IPackageManager#getInstallLocation()} | |
| */ | |
| public static int getInstallLocation() { | |
| CommandResult commandResult = ShellUtils.execCommand("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm get-install-location", | |
| false, true); |
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
| use | |
| Typeface typeface = Typeface.createFromAsset(assetManager, filePath) | |
| and cache it | |
| from: https://github.com/chrisjenx/Calligraphy/blob/master/calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/TypefaceUtils.java |
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
| System.out.println(org.apache.commons.codec.digest.DigestUtils.md5Hex(new FileInputStream("E:\\trinea-android-demo.apk"))); | |
| System.out.println(org.apache.commons.codec.digest.DigestUtils.sha1Hex(new FileInputStream("E:\\trinea-android-demo.apk"))); | |
| System.out.println(org.apache.commons.codec.digest.DigestUtils.sha512Hex(new FileInputStream("E:\\trinea-android-demo.apk"))); | |
| download url: http://commons.apache.org/proper/commons-codec/download_codec.cgi | |
| api guide: http://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/digest/DigestUtils.html |
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
| Class<?> SystemProperties = Class.forName("android.os.SystemProperties"); | |
| Method method = SystemProperties.getMethod("get", new Class[] { String.class }); | |
| ArrayList<String> servers = new ArrayList<String>(); | |
| for (String name : new String[] { "net.dns1", "net.dns2", "net.dns3", "net.dns4", }) { | |
| String value = (String) method.invoke(null, name); | |
| if (value != null && !"".equals(value) && !servers.contains(value)) | |
| servers.add(value); | |
| } |
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 setSearchViewOnClickListener(View v, OnClickListener listener) { | |
| if (v instanceof ViewGroup) { | |
| ViewGroup group = (ViewGroup)v; | |
| int count = group.getChildCount(); | |
| for (int i = 0; i < count; i++) { | |
| View child = group.getChildAt(i); | |
| if (child instanceof LinearLayout || child instanceof RelativeLayout) { | |
| setSearchViewOnClickListener(child, listener); | |
| } |