編輯:Android 資訊
熱修復已經是中型以上項目的標配模塊。原因很現實:應用上線之後出問題幾乎是常態,而靠發版修復的成本實在太高——重新走一遍商店審核、等用戶升級,修復窗口動輒以週計。
目前主流方案有阿里的 AndFix、QZone 的方案、美團基於 Instant Run 思路的方案,以及騰訊的 Tinker。簡單對比:
如果限定開源方案,Tinker 目前基本是首選。它的介紹裡有句話頗有底氣:
Tinker 已運行在微信的數億 Android 設備上,那麼為什麼你不使用 Tinker 呢?
接下來先看接入,再看它大致的工作機制。
Tinker 提供了命令行與 gradle 兩種接入方式。由於早期用 AndFix 的項目不少,加上很多人覺得 gradle 配置繁瑣,這裡兩種都講。
先理清前提(假設已開啟混淆):
Application#onCreate 中初始化,然後在某處調用類似 loadPatch 的 API 加載補丁;dependencies { // ... //可選,用於生成application類 provided('com.tencent.tinker:tinker-android-anno:1.7.7') //tinker的核心庫 compile('com.tencent.tinker:tinker-android-lib:1.7.7') }
android{ //... signingConfigs { release { try { storeFile file("release.keystore") storePassword "testres" keyAlias "testres" keyPassword "testres" } catch (ex) { throw new InvalidUserDataException(ex.toString()) } } } buildTypes { release { minifyEnabled true signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable true minifyEnabled true signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
文末有 demo 地址,可以直接對照其中的 build.gradle,不必糾結簽名檔從哪來。
API 只有兩件事:初始化與加載補丁。常識做法是在 Application#onCreate 裡初始化,但 Tinker 推薦下面這種寫法:
@DefaultLifeCycle(application = ".SimpleTinkerInApplication", flags = ShareConstants.TINKER_ENABLE_ALL, loadVerifyFlag = false) public class SimpleTinkerInApplicationLike extends ApplicationLike { public SimpleTinkerInApplicationLike(Application application, int tinkerFlags, boolean tinkerLoadVerifyFlag, long applicationStartElapsedTime, long applicationStartMillisTime, Intent tinkerResultIntent) { super(application, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime, tinkerResultIntent); } @Override public void onBaseContextAttached(Context base) { super.onBaseContextAttached(base); } @Override public void onCreate() { super.onCreate(); TinkerInstaller.install(this); } }
顧名思義,ApplicationLike 並不是 Application 的子類,而是一個「像 Application 一樣被使用」的類。頂部那個 @DefaultLifeCycle 注解的 application 屬性,會在編譯期生成一個名為 SimpleTinkerInApplication 的類。
也就是說,儘管我們自己沒寫 Application,它會在編譯期被造出來,所以 manifest 裡是這樣寫的:
<application android:name=".SimpleTinkerInApplication" .../>
如果 IDE 報紅,build 一次即可。這背後是一個 Annotation Processor 在工作,原理可參考《Android 如何編寫基於編譯時注解的項目》。
初始化完成後,加載補丁的時機自行決定,示例裡放了一個按鈕:
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void loadPatch(View view) { TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), Environment.getExternalStorageDirectory().getAbsolutePath() + "/patch_signed.apk"); } }
補丁檔直接 push 到 sdcard 根目錄,因此別忘了讀寫權限:
6.x 以上系統需要自行加上動態授權邏輯,或在設置頁手動開啟 SDCard 讀寫權限。
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
另外還有一個容易漏掉的地方:manifest 中必須指定 TINKER_ID。
<application> <meta-data android:name="TINKER_ID" android:value="tinker_id_6235657" /> //... </application>
Tinker 提供了獨立的補丁生成工具(源碼在 tinker-patch-cli),打成 jar 即可使用:
java -jar tinker-patch-cli-1.7.7.jar -old old.apk -new new.apk -config tinker_config.xml -out output
需要留意 tinker_config.xml,裡面是簽名檔等配置。本例直接沿用 Tinker 自帶的簽名檔,只需把 Application 那一項改成本例的類名:
<loader value="com.zhy.tinkersimplein.SimpleTinkerInApplication"/>
目錄結構大致如下:

這些檔可以從 tinker-patch-cli 中提取,也可以直接下載文末的例子。
還有一個至關重要的動作:第一次出包時務必保留 mapping 檔,位於 /build/outputs/mapping/release/mapping.txt。把它拷到與 proguard-rules.pro 同目錄,並在第二次打修復包時於 proguard-rules.pro 中加上:
-applymapping mapping.txt
這樣後續構建才會與線上包使用同一份混淆規則。Tinker 自身的混淆配置可參考 tinker_proguard.pro。
先按上述配置打一個 apk 裝到手機或模擬器上,然後拷出 mapping.txt、配置好 applymapping,改一點代碼再打一次包得到 new.apk,用上面的命令生成補丁。
產物在 output 目錄:

把 patch_signed.apk push 到 sdcard,點擊 loadPatch,並盯緊日誌:

本例改的是 title。加載成功後應用會默認重啟,再次打開就能看到修復效果。
以上只演示了最小接入。真要落地,Tinker 的各項配置參數還是得翻一遍官方文檔。
這才是主流方式,Tinker 也直接給了例子:把 tinker-sample-android 單獨以 project 方式導入即可,裡面同時展示了 API 接入方式與各項配置。
每次 build 之後,build/bakApk 下會生成本地構建產物:apk、R 檔、mapping 檔。要生成補丁執行:
./gradlew tinkerPatchRelease // 或者 ./gradlew tinkerPatchDebug
產物位於 build/outputs/tinkerPatch:

關鍵是在 app/build.gradle 中指定基準包(old.apk):
ext { tinkerEnabled = true //old apk file to build patch apk tinkerOldApkPath = "${bakPath}/old.apk" //proguard mapping file to build patch apk tinkerApplyMappingPath = "${bakPath}/old-mapping.txt" }
示例基本覆蓋了 Tinker 的擴展方式。即使你走命令行路線,也建議順手了解一下它支持哪些擴展項。
從註釋就能看出這是 anno 模組的功勞:
//可選,用於生成application類 provided('com.tencent.tinker:tinker-android-anno:1.7.7')
結構是典型的編譯時注解項目:

入口類是 com.tencent.tinker.anno.AnnotationProcessor,其全路徑聲明在 services/javax.annotation.processing.Processor 中。process 方法很乾脆:
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { processDefaultLifeCycle(roundEnv.getElementsAnnotatedWith(DefaultLifeCycle.class)); return true; }
private void processDefaultLifeCycle(Set<? extends Element> elements) { // 被注解DefaultLifeCycle標識的對象 for (Element e : elements) { DefaultLifeCycle ca = e.getAnnotation(DefaultLifeCycle.class); String lifeCycleClassName = ((TypeElement) e).getQualifiedName().toString(); String lifeCyclePackageName = lifeCycleClassName.substring(0, lifeCycleClassName.lastIndexOf('.')); lifeCycleClassName = lifeCycleClassName.substring(lifeCycleClassName.lastIndexOf('.') + 1); String applicationClassName = ca.application(); if (applicationClassName.startsWith(".")) { applicationClassName = lifeCyclePackageName + applicationClassName; } String applicationPackageName = applicationClassName.substring(0, applicationClassName.lastIndexOf('.')); applicationClassName = applicationClassName.substring(applicationClassName.lastIndexOf('.') + 1); String loaderClassName = ca.loaderClass(); if (loaderClassName.startsWith(".")) { loaderClassName = lifeCyclePackageName + loaderClassName; } final InputStream is = AnnotationProcessor.class.getResourceAsStream(APPLICATION_TEMPLATE_PATH); final Scanner scanner = new Scanner(is); final String template = scanner.useDelimiter("\\A").next(); final String fileContent = template .replaceAll("%PACKAGE%", applicationPackageName) .replaceAll("%APPLICATION%", applicationClassName) .replaceAll("%APPLICATION_LIFE_CYCLE%", lifeCyclePackageName + "." + lifeCycleClassName) .replaceAll("%TINKER_FLAGS%", "" + ca.flags()) .replaceAll("%TINKER_LOADER_CLASS%", "" + loaderClassName) .replaceAll("%TINKER_LOAD_VERIFY_FLAG%", "" + ca.loadVerifyFlag()); JavaFileObject fileObject = processingEnv.getFiler().createSourceFile(applicationPackageName + "." + applicationClassName); processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Creating " + fileObject.toUri()); Writer writer = fileObject.openWriter(); PrintWriter pw = new PrintWriter(writer); pw.print(fileContent); pw.flush(); writer.close(); } }
可以拆成三步理解:
@DefaultLifeCycle 標註的元素(TypeElement),取出包名、類名,再從注解中讀出各項屬性;模板本身很短:
package %PACKAGE%; import com.tencent.tinker.loader.app.TinkerApplication; /** * * Generated application for tinker life cycle * */ public class %APPLICATION% extends TinkerApplication { public %APPLICATION%() { super(%TINKER_FLAGS%, "%APPLICATION_LIFE_CYCLE%", "%TINKER_LOADER_CLASS%", %TINKER_LOAD_VERIFY_FLAG%); } }
佔位符的含義:包名(application 屬性以點開頭則同包,否則截取)、類名、flags、ApplicationLike 的全路徑、loaderClass(默認 com.tencent.tinker.loader.TinkerLoader)、loadVerifyFlag。代入後生成的就是:
/** * * Generated application for tinker life cycle * */ public class SimpleTinkerInApplication extends TinkerApplication { public SimpleTinkerInApplication() { super(7, "com.zhy.tinkersimplein.SimpleTinkerInApplicationLike", "com.tencent.tinker.loader.TinkerLoader", false); } }
官方對此的解釋是:為了減少錯誤出現,推薦用注解生成 Application 類。畢竟手寫的話,一旦 constructor 的參數順序或個數寫錯,問題會非常隱蔽。

來源:https://github.com/Tencent/tinker
流程是:對 old.apk 與 new.apk 做 diff 得到 patch.dex,下發到設備後與本機 apk 中的 classes.dex 合併成一份新的完整 dex,運行時通過反射把合併後的 dex 插到 dexElements 陣列前面。
「運行時替換」的思路與 QZone 方案同源,差別在插入的內容:QZone 直接插入 patch.dex,Tinker 插入的是合併後的全量 dex。之所以換個做法,是因為 QZone 方案在 CLASS_ISPREVERIFIED 上的處理存在缺陷,Tinker 等於繞開了這個坑。
接下來用代碼驗證,跟著兩條線走:應用啟動時如何加載已合併的 dex;補丁下發後如何合成 dex。
加載發生在生成的 Application 中。其父類 TinkerApplication 在 attachBaseContext 裡輾轉調用 loadTinker(),後者反射調用 TinkerLoader 的 tryLoad:
@Override public Intent tryLoad(TinkerApplication app, int tinkerFlag, boolean tinkerLoadVerifyFlag) { Intent resultIntent = new Intent(); long begin = SystemClock.elapsedRealtime(); tryLoadPatchFilesInternal(app, tinkerFlag, tinkerLoadVerifyFlag, resultIntent); long cost = SystemClock.elapsedRealtime() - begin; ShareIntentUtil.setIntentPatchCostTime(resultIntent, cost); return resultIntent; }
private void tryLoadPatchFilesInternal(TinkerApplication app, int tinkerFlag, boolean tinkerLoadVerifyFlag, Intent resultIntent) { // 省略大量安全性校驗代碼 if (isEnabledForDex) { //tinker/patch.info/patch-641e634c/dex boolean dexCheck = TinkerDexLoader.checkComplete(patchVersionDirectory, securityCheck, resultIntent); if (!dexCheck) { Log.w(TAG, "tryLoadPatchFiles:dex check fail"); return; } } if (isEnabledForDex) { boolean loadTinkerJars = TinkerDexLoader.loadTinkerJars(app, tinkerLoadVerifyFlag, patchVersionDirectory, resultIntent, isSystemOTA); if (!loadTinkerJars) { Log.w(TAG, "tryLoadPatchFiles:onPatchLoadDexesFail"); return; } } }
checkComplete 負責核對 meta 檔(產物中的 assets/dex-meta.txt)裡記錄的 dex 資訊,確認每個 dex 檔都存在,並把它們存進 TinkerDexLoader 的靜態變數 dexList。
loadTinkerJars 的第五個參數表示當前補丁是否只適用於 Art:
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean loadTinkerJars(Application application, boolean tinkerLoadVerifyFlag, String directory, Intent intentResult, boolean isSystemOTA) { PathClassLoader classLoader = (PathClassLoader) TinkerDexLoader.class.getClassLoader(); String dexPath = directory + "/" + DEX_PATH + "/"; File optimizeDir = new File(directory + "/" + DEX_OPTIMIZE_PATH); ArrayList<File> legalFiles = new ArrayList<>(); final boolean isArtPlatForm = ShareTinkerInternals.isVmArt(); for (ShareDexDiffPatchInfo info : dexList) { //for dalvik, ignore art support dex if (isJustArtSupportDex(info)) { continue; } String path = dexPath + info.realName; File file = new File(path); legalFiles.add(file); } if (isSystemOTA) { parallelOTAResult = true; parallelOTAThrowable = null; Log.w(TAG, "systemOTA, try parallel oat dexes!!!!!"); TinkerParallelDexOptimizer.optimizeAll( legalFiles, optimizeDir, new TinkerParallelDexOptimizer.ResultCallback() { } ); SystemClassLoaderAdder.installDexes(application, classLoader, optimizeDir, legalFiles); return true; }
真正幹活的是 installDexes:
@SuppressLint("NewApi") public static void installDexes(Application application, PathClassLoader loader, File dexOptDir, List<File> files) throws Throwable { if (!files.isEmpty()) { ClassLoader classLoader = loader; if (Build.VERSION.SDK_INT >= 24) { classLoader = AndroidNClassLoader.inject(loader, application); } //because in dalvik, if inner class is not the same classloader with it wrapper class. //it won't fail at dex2opt if (Build.VERSION.SDK_INT >= 23) { V23.install(classLoader, files, dexOptDir); } else if (Build.VERSION.SDK_INT >= 19) { V19.install(classLoader, files, dexOptDir); } else if (Build.VERSION.SDK_INT >= 14) { V14.install(classLoader, files, dexOptDir); } else { V4.install(classLoader, files, dexOptDir); } sPatchDexCount = files.size(); Log.i(TAG, "after loaded classloader: " + classLoader + ", dex size:" + sPatchDexCount); if (!checkDexInstall(classLoader)) { SystemClassLoaderAdder.uninstallPatchDex(classLoader); throw new TinkerRuntimeException(ShareConstants.CHECK_DEX_INSTALL_FAIL); } } }
按系統版本分派到不同的反射實現。以 V19 為例:
private static final class V19 { private static void install(ClassLoader loader, List<File> additionalClassPathEntries, File optimizedDirectory) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, InvocationTargetException, NoSuchMethodException, IOException { Field pathListField = ShareReflectUtil.findField(loader, "pathList"); Object dexPathList = pathListField.get(loader); ArrayList<IOException> suppressedExceptions = new ArrayList<IOException>(); ShareReflectUtil.expandFieldArray(dexPathList, "dexElements", makeDexElements(dexPathList, new ArrayList<File>(additionalClassPathEntries), optimizedDirectory, suppressedExceptions)); if (suppressedExceptions.size() > 0) { for (IOException e : suppressedExceptions) { Log.w(TAG, "Exception in makeDexElement", e); throw e; } } } }
步驟很清晰:取出 PathClassLoader(BaseDexClassLoader)的 pathList 對象;反射調用它的 makeDexElements 把補丁 dex 轉成 Element 陣列;取出原有的 dexElements;兩者合併並把補丁放在前面;最後寫回 pathList。核心與 QZone 方案一致。
入口就是我們調用的那句:
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), Environment.getExternalStorageDirectory().getAbsolutePath() + "/patch_signed.apk");
它會走到 DefaultPatchListener:
# DefaultPatchListener @Override public int onPatchReceived(String path) { int returnCode = patchCheck(path); if (returnCode == ShareConstants.ERROR_PATCH_OK) { TinkerPatchService.runPatchService(context, path); } else { Tinker.with(context).getLoadReporter().onLoadPatchListenerReceiveFail(new File(path), returnCode); } return returnCode; }
先做開關與合法性校驗,通過則啟動服務:
public static void runPatchService(Context context, String path) { try { Intent intent = new Intent(context, TinkerPatchService.class); intent.putExtra(PATCH_PATH_EXTRA, path); intent.putExtra(RESULT_CLASS_EXTRA, resultServiceClass.getName()); context.startService(intent); } catch (Throwable throwable) { TinkerLog.e(TAG, "start patch service fail, exception:" + throwable); } }
TinkerPatchService 是 IntentService 的子類,intent 裡帶了補丁路徑和結果回調類(默認 DefaultTinkerResultService,在 Tinker.install 時指定)。直接看 onHandleIntent:
@Override protected void onHandleIntent(Intent intent) { final Context context = getApplicationContext(); Tinker tinker = Tinker.with(context); String path = getPatchPathExtra(intent); File patchFile = new File(path); boolean result; increasingPriority(); PatchResult patchResult = new PatchResult(); result = upgradePatchProcessor.tryPatch(context, path, patchResult); patchResult.isSuccess = result; patchResult.rawPatchFilePath = path; patchResult.costTime = cost; patchResult.e = e; AbstractResultService.runResultService(context, patchResult, getPatchResultExtra(intent)); }
這裡有個有意思的細節 increasingPriority():
private void increasingPriority() { TinkerLog.i(TAG, "try to increase patch process priority"); try { Notification notification = new Notification(); if (Build.VERSION.SDK_INT < 18) { startForeground(notificationId, notification); } else { startForeground(notificationId, notification); // start InnerService startService(new Intent(this, InnerService.class)); } } catch (Throwable e) { TinkerLog.i(TAG, "try to increase patch process priority error:" + e); } }
熟悉「進程保活」話題的人對這段一定不陌生——合成補丁是耗時的 IO 操作,一旦進程被回收,補丁就白打了,所以要設法抬高進程優先級。
回到 tryPatch:
# UpgradePatch @Override public boolean tryPatch(Context context, String tempPatchPath, PatchResult patchResult) { Tinker manager = Tinker.with(context); final File patchFile = new File(tempPatchPath); //it is a new patch, so we should not find a exist SharePatchInfo oldInfo = manager.getTinkerLoadResultIfPresent().patchInfo; String patchMd5 = SharePatchFileUtil.getMD5(patchFile); //use md5 as version patchResult.patchVersion = patchMd5; SharePatchInfo newInfo; if (oldInfo != null) { newInfo = new SharePatchInfo(oldInfo.oldVersion, patchMd5, Build.FINGERPRINT); } else { newInfo = new SharePatchInfo("", patchMd5, Build.FINGERPRINT); } final String patchDirectory = manager.getPatchDirectory().getAbsolutePath(); final String patchName = SharePatchFileUtil.getPatchVersionDirectory(patchMd5); final String patchVersionDirectory = patchDirectory + "/" + patchName; File destPatchFile = new File(patchVersionDirectory + "/" + SharePatchFileUtil.getPatchVersionFile(patchMd5)); if (!patchMd5.equals(SharePatchFileUtil.getMD5(destPatchFile))) { SharePatchFileUtil.copyFileUsingStream(patchFile, destPatchFile); } //we use destPatchFile instead of patchFile, because patchFile may be deleted during the patch process if (!DexDiffPatchInternal.tryRecoverDexFiles(manager, signatureCheck, context, patchVersionDirectory, destPatchFile)) { TinkerLog.e(TAG, "UpgradePatch tryPatch:new patch recover, try patch dex failed"); return false; } return true; }
這裡有兩個值得注意的設計:版本號直接用補丁檔的 md5;以及先把補丁拷到私有目錄再操作——因為 sdcard 上的原檔隨時可能被用戶或系統刪掉,合成過程必須依賴自己掌控的副本。
protected static boolean tryRecoverDexFiles(Tinker manager, ShareSecurityCheck checker, Context context, String patchVersionDirectory, File patchFile) { String dexMeta = checker.getMetaContentMap().get(DEX_META_FILE); boolean result = patchDexExtractViaDexDiff(context, patchVersionDirectory, dexMeta, patchFile); return result; }
private static boolean patchDexExtractViaDexDiff(Context context, String patchVersionDirectory, String meta, final File patchFile) { String dir = patchVersionDirectory + "/" + DEX_PATH + "/"; if (!extractDexDiffInternals(context, dir, meta, patchFile, TYPE_DEX)) { TinkerLog.w(TAG, "patch recover, extractDiffInternals fail"); return false; } final Tinker manager = Tinker.with(context); File dexFiles = new File(dir); File[] files = dexFiles.listFiles(); return true; }
private static boolean extractDexDiffInternals(Context context, String dir, String meta, File patchFile, int type) { //parse meta ArrayList<ShareDexDiffPatchInfo> patchList = new ArrayList<>(); ShareDexDiffPatchInfo.parseDexDiffPatchInfo(meta, patchList); File directory = new File(dir); Tinker manager = Tinker.with(context); ZipFile apk = null; ZipFile patch = null; ApplicationInfo applicationInfo = context.getApplicationInfo(); String apkPath = applicationInfo.sourceDir; apk = new ZipFile(apkPath); patch = new ZipFile(patchFile); for (ShareDexDiffPatchInfo info : patchList) { final String infoPath = info.path; String patchRealPath; if (infoPath.equals("")) { patchRealPath = info.rawName; } else { patchRealPath = info.path + "/" + info.rawName; } File extractedFile = new File(dir + info.realName); ZipEntry patchFileEntry = patch.getEntry(patchRealPath); ZipEntry rawApkFileEntry = apk.getEntry(patchRealPath); patchDexFile(apk, patch, rawApkFileEntry, patchFileEntry, info, extractedFile); } return true; }
先解析 meta 拿到每個 dex 的描述,然後通過 ApplicationInfo.sourceDir 定位本機 apk,同時打開補丁包,逐項取出對應的舊 dex 與補丁數據,交給 patchDexFile 合併:
private static void patchDexFile( ZipFile baseApk, ZipFile patchPkg, ZipEntry oldDexEntry, ZipEntry patchFileEntry, ShareDexDiffPatchInfo patchInfo, File patchedDexFile) throws IOException { InputStream oldDexStream = null; InputStream patchFileStream = null; oldDexStream = new BufferedInputStream(baseApk.getInputStream(oldDexEntry)); patchFileStream = (patchFileEntry != null ? new BufferedInputStream(patchPkg.getInputStream(patchFileEntry)) : null); new DexPatchApplier(oldDexStream, patchFileStream).executeAndSaveTo(patchedDexFile); }
兩路 InputStream 進、合併後的 dex 落到私有目錄出。DexPatchApplier 才是 Tinker 真正的核心,它與 dex 格式緊密耦合,本文不展開,有興趣可移步《Tinker Dexdiff 算法解析》。
至此,Tinker 熱修復的完整鏈路就閉環了:構建期 diff 出補丁 → 下發 → 合成全量 dex 落私有目錄 → 下次啟動反射插到 dexElements 最前面。
測試 demo:https://github.com/WanAndroid/tinkerTest
後續還可以繼續看資源的熱修、so 的熱修,以及 gradle 插件的實現。
Android ActionBar 中 Overflow Menu 的相容問題
前言 Overflow Menu 是 ActionBar 右上角的溢出菜單,通常用來放次要操作。不同廠牌 ROM 對它的處理不一致,因此需要額外套路來相容。 什麼是
Android 記憶體洩漏的 8 種常見陷阱
Java 是垃圾回收語言,這意味著開發者不必特別管理記憶體配置,既降低了因局部故障(segmentation fault)導致崩潰的機率,也避免了未釋放的記憶體把堆(he
甲骨文訴谷歌終落幕:Android 生態與 Java 社區的雙重勝利
BI 中文站 5 月 27 日報道 美國陪審團的裁決剛剛揭曉:在甲骨文指控谷歌侵權一案中,甲骨文敗訴。陪審團認為,谷歌使用爭議程式碼屬於「合理使用」(fair use)。
一個簡單易用的 Android 頂部導航欄 TitleBar
這是一個簡單易用的導航欄 TitleBar,能輕鬆實現各種類似 iOS 導航欄的效果。全部代碼集中在 TitleBar.java 中,所有控件都動態生成、動態佈局,無需引