[android] Droid Pirate에 실린 개발자가 라이프사이클과 관련해서 겪는 실수 동영상을 보고 나름 정리해보았다. 놓치고 있던 부분들이 많은것 같아 상당히 유익한 동영상이었다.

False Assumption #3

Using configCahnges is a cheap way to correctly handle configuration change

False Assumption #4

it it possible to reliably prevent your activity from restarting

엑티비티가 재시작하는 이유

False Assumption #6

If i check for a permission before launching an activity that needs it,the new Activity doesn’t need permission Check

False Assumption #7

My initialization logic will always be executed at least once before my UI is shown.

class SplashActivity : AppCompatActiviy(){
  override fun onCreate(ssavedInstanceState : Bundle?){
    super.onCreate(savedIntacneState)
    // some required initialization work
    
    initializeReallyImportanteAppData()
    startActivity(MainActivity.newIntent(this))
    finish()
  }
}

False Assumption #8

I can safely pass Fragment arguments as properties or with constructors

False Assumption #9

The only limitation of Fragment argmuents and saved state Bundles is the type of data.

img

어떤 에러를 보여주고 싶을 때

  1. AlertDialog : rotate,configuration chagne 등으로인해 엑티비티 재시작 후엔 사라진다. 나쁜 방법

  2. Generic dialog fragment

    img

putParcelabe(ARG_CALLBACK,onDeleteAlbmumConfirmed)

-> Navigation Library를 사용중이라면 이줄에서 두가지 에러를 보게될것

Execution failed for task 'app:generateSafeArgsDebug' > Can't escape identifier '() -> Unit' because it contain illegal characters: >

UnsupportedOperationException : ErrorCallback must implement Parceralbe or Serializable or must be on Enum.

False Assumption #10

There is a safe way of passing Lambda epressions as Fragment arguments

False Assumption #11

I can perform Fragment transcations and navigation events whenever i want

Embrace Activity & Fragment recreations

Tolerate process eviction

—영상 링크 —

https://www.droidcon.com/media-detail?video=443146897