『Android Kotlin Fundamentals』をやった(4)

Android Kotlin Fundamentals: Lifecycles and logging

3. Explore the lifecycle methods and add basic logging

Step 1: Examine the onCreate() method and add logging


4. Use Timber for logging

Step 2: Create an Application class and initialize Timber

Warning: It might be tempting to add your own code to the Application class, because the class is created before all of your activities and can hold global state. But just as it's error-prone to make readable and writable static variables that are globally available, it's easy to abuse the Application class. Avoid putting any activity code in the Application class unless the code is really needed.


5. Explore lifecycle use cases

Use case 3: Partially hide the activity

Whatever code runs in onPause() blocks other things from displaying, so keep the code in onPause() lightweight.

onPause()内は軽めに…φ(・ω・` )メモメモ…

6. Explore the fragment lifecycle

Lifecycles and loggingの後は次のComplex Lifecycle Situationsへのリンクがない?

Android Kotlin Fundamentals: Complex Lifecycle Situations

4. Task: Use the Android lifecycle library

Step 1: Turn DessertTimer into a LifecycleObserver


5. Task: Simulate app shutdown and use onSaveInstanceState()

Step 1: Use adb to simulate a process shutdown

The Android Debug Bridge (adb) is a command-line tool that lets you send instructions to emulators and devices attached to your computer.

Android Debug Bridge(adb)はコンピュータに接続されたデバイスまたはエミュレータへ指示を送るコマンドラインツールと…φ(・ω・` )メモメモ…

4.Type adb and press Return.

adb shell am kill com.example.android.dessertclicker
が上手く動いてないのか、Recents Screenから復帰(?)させても、前の状態が残ってるな…

adb server version (41) doesn't match this client (40); killing...
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon


コマンドプロンプトで上のコマンドを放ったら、何のエラーメッセージも出さずに終了出来た模様。Recents Screenから復帰させたら、無事に前の状態がリセットされていた。


Step 2: Use onSaveInstanceState() to save bundle data

A bundle is a collection of key-value pairs, where the keys are always strings.


Generally you should store far less than 100k, otherwise you risk crashing your app with the TransactionTooLargeException error.

サイズは100KB以下に抑えないと駄目と…φ(・ω・` )メモメモ…

The putInt() method (and similar methods from the Bundle class like putFloat() and putString() takes two arguments:

Step 3: Use onCreate() to restore bundle data

So if the bundle is not null, you know you're "re-creating" the activity from a previously known point.


which in turn
which in turnって何?非制限用法(付加用法)って?
「which in turn,」の訳し方について 下記の文章で「which in turn,」はどう訳せば良いでし…