Android
-
#3 Coroutine 형식Android/Coroutine 2021. 10. 10. 14:31
서론 #2에서 Coroutine 구성요소를 살펴봤다. 이제는 실제 Coroutine이 사용되는 형식을 살펴보겠다. 1. Suspend suspend fun myCoroutine() { delay(1000) println("myCoroutine") } #1에서 잠깐 언급한 suspend다. 위와 같이 어떠한 함수 내부에서 Coroutine(suspend function)을 실행할 수 있게 만들어주려면 suspend 라는 단어를 붙여주어야 한다. suspend를 붙여줌으로써 해당 함수는 하나의 Coroutine으로 동작하기 위한 자격을 얻게되며, 일시중지 및 재개(suspend & resume)이 가능해진다. 이렇게 만들어진 suspend function은 아무데서나 사용될 수 없고 어떠한 Coroutine..
-
#2 Coroutine 구성요소Android/Coroutine 2021. 10. 6. 15:02
서론 #1에서는 Coroutine의 작동 방식과, 장점에 대해 간단히 살펴보았다. 이번 #2에서는 Coroutine의 기본적인 형태와 구성요소에 대해 살펴볼 것이다. Coroutine 만들기 일반적인 Coroutine은 아래와 같은 형태를 갖는다. val scope = CoroutineScope(CoroutineContext) val job = scope.CoroutineBuilder{ //Do Something } 위의 코드는 클래스의 이름을 이용해 나타낸 것이고 실제 코드에서 사용하는 예시는 다음과 같다. val scope = CoroutineScope(Dispatchers.IO) //CoroutineScope 생성 val job = scope.launch{ //아래 코드를 방금 만들어준 Corout..
-
#1. Why CoroutineAndroid/Coroutine 2021. 10. 5. 17:20
서론 안드로이드에서 비동기 백그라운드 작업을 하는 AsyncTask가 @Deprecated가 붙고 이 커밋에서 다음과 같은 코멘트가 남겨졌다. AsyncTask was intended to enable proper and easy use of the UI thread. However, the most common use case was for integrating into UI, and that would cause Context leaks, missed callbacks, or crashes on configuration changes. It also has inconsistent behavior on different versions of the platform, swallows exceptions ..
-
Firebase Realtime DB RulesAndroid 2021. 9. 29. 11:42
Rule Types .read - 사용자가 데이터를 읽을 수 있도록 하는 규칙을 정의한다. .write - 사용자가 데이터를 쓸 수 있도록 하는 규칙을 정의한다. .validate - 데이터가 어떤 형태를 가져야 하는지, 자식 속성을 가지는지, 데이터 타입 등을 정의한다. .indexOn - 정렬 및 쿼리를 위해 색인화할 하위 항목을 지정한다. Firebase Realtime DB Template 1) No Security 이 규칙은 어느 앱에서 누구나 DB에 접근할 수 있도록 한다. 개발 단계에서는 간편할 수 있지만, 이 수준의 규칙은 누구나 접근할 수 있기 때문에 앱을 런칭하기 전에는 수정이 필요하다. // No Security { “rules”: { “.read”: true, “.write”: tr..
-
What is Context in AndroidAndroid 2021. 9. 27. 15:42
What is Context Context란 이미 많은 개발 분야에서 사용된다. Context 는 한국말로 직역하면 문맥, 맥락이란 단어이다. 안드로이드 공식 사이트에서는 아래와 같이 기술 되어있는데 Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching act..