본문 바로가기

Android5

[안드로이드] UI 요소 지연 초기화 1. 개요 코틀린에서 Non-null로 선언된 프로퍼티는 선언과 동시에 초기화해야 한다. 만일 초기화 하지 않으면 'Property must be initialized or be abstract' 라는 에러 메시지가 발생한다. 특정 UI 요소를 여러 콜백 함수에서 사용할 때 지연 초기화를 사용하면 유용하다. 2. 지연 초기화 기법 코틀린에서 지연 초기화를 위한 두 가지 방법을 제공한다. lateinit by lazy 자세한 내용은 공식 사이트를 참고한다. 3. 소스코드 다음은 MainActivity.kt의 일부 소스코드이다. class MainActivity : AppCompatActivity() { private lateinit var displayTextView: TextView // .. 2021. 6. 11.
[안드로이드] App Components - Content Provider Content Provider란? 안드로이드 개발자 사이트에서 Content Provider는 다음과 같이 설명하고 있다. Content providers can help an application manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps. Link: Google Developer 즉, Content Provider는 애플리케이션의 저장된 데이터와 다른 앱이 저장한 데이터에 대한 액세스 권한을 관리하도록 돕고 데이터를 공유하는 방법을 제공한다. 장점 데이터 액세스 권한에 대한 세분화된 제어 기능을 제공한다. 자세한 내용은 콘텐츠 제공자 권한을 참조한다.. 2021. 6. 8.
[안드로이드] App Components - Broadcast Receiver Broadcast Receiver란? 안드로이드 개발자 사이트에서 Broadcast Receiver는 다음과 같이 설명하고 있다. A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements. Link: Google Developer 즉, Broadcast Receiver는 시스템 또는 앱에서 발생한 이벤트에 대해 알림 역할을 수행한다. (e.g. 배터리 부족, 기기 충전) Broadcast Receiver 수신 앱은 Manifest.. 2021. 6. 4.
[안드로이드] App Components - Service Service란? 안드로이드 개발자 사이트에서 Service는 다음과 같이 설명하고 있다. A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons. It is a component that runs in the background to perform long-running operations or to perform work for remote processes. Link: Google Developer 즉, Service는 백그라운드에서 앱을 계속 실행하기 위한 진입점으로 오랫동안 실행되는 작업이나 원격 프로세스를 위한 작업을 수행한다. 서비스의 세 가지 유.. 2021. 5. 27.