CN

loading
Android Tips Round-Up, Part 2

For the second Chinese post in this series, I translated Dan Lew’s Android Tips Round-Up. As in the first part, I’ve added notes from using some of these tools and filled in explanations where I thought they would help. If a few of the APIs are new to you, I hope the list comes in handy. The API updates are noted below.

Reviewed 2026-10-13: This 2014 list covers View and system utility APIs. Activity.onBackPressed() was deprecated in API 33, and text layout has a Builder API from API 23. The notes below add replacements and correct the explanations of alarms, application memory, and screen density.

Android Tips Round-Up, Part 1

Reviewed 2026-10-13: This 2014 list focuses on Android’s View system. Most APIs remain valid. The old Html.fromHtml(String) overload was deprecated in API 24; the notes below add its replacement and correct the descriptions of cache directories, layout inflation, and reverse playback.

For the first Chinese post in this series, I translated Dan Lew’s Android Tips Round-Up. You may already know some of these small SDK tools; I’m writing them down in case a few are new to you. It isn’t a word-for-word translation. I use some of these classes myself, so I’ve added my own notes and explanations where I thought they would help. This English edition includes the API updates below.

Android Tools - Log2File

Updated 2026-10-13: The 2014 implementation wrote directly under the external-storage root, which is outdated. Android 10 (API 29) introduced scoped storage; Android 11 (API 30) ignores requestLegacyExternalStorage for apps targeting API 30 or higher. The replacement below uses app-internal storage, requires Android 4.4 (API 19) or later, and needs no storage permission. See Android 11 storage changes.

Log2File records logs explicitly supplied by an Android application to a file. It is useful when:

  1. A computer cannot be connected for debugging, for example because USB OTG occupies the port.
  2. Logs are difficult to capture in real time.
  3. An intermittent bug requires a record of the operations preceding it.
  4. I’ll leave the other uses to your imagination.

It saves only the content passed to w(); it does not automatically capture system logcat. Use the Logcat tools for system logging.

0. Introduction

This article originally appeared on my CSDN blog before moving here. The original GitHub source URL returned 404 during this update, so the replacement implementation is included below.