實作一個程式,可以透過給定 url,下載資料內容,下載圖片。
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
apply plugin: 'com.android.application' | |
buildscript { | |
repositories { | |
maven { url 'https://maven.fabric.io/public' } | |
} | |
dependencies { | |
classpath 'io.fabric.tools:gradle:1.+' | |
} |
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
try { | |
String appVersion = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; | |
SharedPreferences.Editor editor = preferences.edit(); | |
editor.putString(PREFERENCES_KEY_APP_VERSION, appVersion); | |
editor.apply(); | |
} catch (PackageManager.NameNotFoundException e) { | |
Log.e(Carce.TAG, e.getLocalizedMessage()); | |
} |
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
try { | |
String appVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; | |
contentAdapter.addItem(new ItemObject("版本 " + appVersion, null)); | |
Signature[] sigs = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures; | |
StringBuffer signBffer = new StringBuffer(); | |
for (Signature sign: sigs) { | |
signBffer.append(sign.toCharsString()); |
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
public static double round(double d, int decimalPlace) { | |
BigDecimal bd = new BigDecimal(d); | |
bd = bd.setScale(decimalPlace, BigDecimal.ROUND_FLOOR); | |
return bd.doubleValue(); | |
} |