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 convertToHexString(byte[] data) { | |
| StringBuilder buf = new StringBuilder(); | |
| for (byte b : data) { | |
| int halfbyte = (b >>> 4) & 15; | |
| int two_halfs = 0; | |
| while (true) { | |
| char c = (halfbyte < 0 || halfbyte > 9) ? (char) ((halfbyte - 10) + 97) : (char) (halfbyte + 48); | |
| buf.append(c); | |
| halfbyte = b & 15; | |
| int two_halfs2 = two_halfs + 1; |
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 final String md5(String s) { | |
| String MD5 = CommonUtils.MD5_INSTANCE; | |
| try { | |
| MessageDigest digest = MessageDigest.getInstance(CommonUtils.MD5_INSTANCE); | |
| digest.update(s.getBytes()); | |
| byte[] messageDigest = digest.digest(); | |
| StringBuilder hexString = new StringBuilder(); | |
| for (byte aMessageDigest : messageDigest) { | |
| String h = Integer.toHexString(aMessageDigest & 255); | |
| while (h.length() < 2) { |
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 class MyApp extends Application { | |
| public static boolean isAppInBackground = false; | |
| private Activity mCurrentActivity; | |
| public void onCreate() { | |
| super.onCreate(); | |
| setScreenOrientation(); | |
| this.mMyApp = (MyApp) getApplicationContext(); |
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 getAppVersionName() { | |
| try { | |
| return MyApplication.getContext().getPackageManager().getPackageInfo(MyApplication.getContext().getPackageName(), 0).versionName; | |
| } catch (Exception ex) { | |
| ex.printStackTrace(); | |
| return "1"; | |
| } | |
| } |
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 Integer getAppVersionCode() { | |
| try { | |
| return Integer.valueOf(MyApplication.getContext().getPackageManager().getPackageInfo(MyApplication.getContext().getPackageName(), 0).versionCode); | |
| } catch (Exception ex) { | |
| ex.printStackTrace(); | |
| return Integer.valueOf(1); | |
| } | |
| } |
NewerOlder