본문 바로가기

Android62

Android BLE 통신하기 BLE 연결은 “파이프 꽂는 것”Bond는 “안전한 문 열쇠 따는 것”둘 다 해야 물 흐른다. 전체 흐름 요약connectGatt()↓STATE_CONNECTED + GATT_SUCCESS ← 파이프 꽂힘↓if (needBond) createBond() ← 문 열쇠 만듦↓ Bonding↓BOND_BONDED ← 열쇠 획득↓discoverServices() ← 안에 뭐 있나 탐색↓onServicesDiscovered OK ← 정식 통신 가능↓MTU 협상 / Notify Enable↓데이터 Read/Write 왜 Bond가 필요한 기기가 있을까? Device 정보 보호Notification 활성화를.. 2025. 11. 28.
2025.11 Android gradle 빌드 최신 버전 ✅ 기록용 빌드 버전libs.version.toml[versions]agp = "8.13.0"kotlin = "2.2.21"coreKtx = "1.17.0"junit = "4.13.2"junitVersion = "1.3.0"espressoCore = "3.7.0"lifecycleRuntimeKtx = "2.9.4"activityCompose = "1.11.0"composeBom = "2025.10.01"navigationCompose = "2.9.5"hilt = "2.57.2"hiltNavigationCompose = "1.3.0"ksp = "2.2.21-2.0.4"[libraries]androidx-core-ktx = { group = "androidx.core", name = "core-ktx", v.. 2025. 11. 5.
Android Compose TextField 천 단위 콤마로 표현하기 📌Util 함수 만들어주기// 천 단위 콤마 변환을 함수로 구현fun thousandSeparatorTransformation(): VisualTransformation { return VisualTransformation { text -> val originalText = text.text val formattedText = originalText.toLongOrNull()?.let { DecimalFormat("#,###").format(it) } ?: originalText val offsetMapping = object : OffsetMapping { override fun originalToTrans.. 2024. 10. 24.
Android ANR / Canvas / 메모리 초과 해결방법 Canvas를 사용하다보면 ANR이슈가 종종 생기는데 이때 개선할 수 있는 방법이 있다.1. Bitmap 객체 재사용하기Bitmap은 메모리 소비가 큰 객체이므로, 반복적인 생성은 메모리 부족 문제를 일으킬 수 있다.var reusableBitmap: Bitmap? = nullfun getReusableBitmap(width: Int, height: Int): Bitmap { if (reusableBitmap == null || reusableBitmap!!.width != width || reusableBitmap!!.height != height) { reusableBitmap?.recycle() // 이전 비트맵을 해제 reusableBitmap = Bitmap.cr.. 2024. 8. 28.
Android Coroutine example 코루틴 권장사항 1. 새 코루틴을 만들거나 withContext를 호출할때 Dispatchers를 하드코딩하지 마세요. -> 코드의 유연성, 테스트 용이성을 위함. 직접 하드코딩하게 되면 테스트나 리팩토링이 어려워진다. 하드코딩된 Dispatchersimport kotlinx.coroutines.*fun fetchData() { GlobalScope.launch(Dispatchers.IO) { // 일부 오래 동작하는 작업 val data = performNetworkRequest() withContext(Dispatchers.Main) { // UI 업데이트 updateUI(data) } }} 하드코딩을 .. 2024. 7. 4.
Compose Box Basic Style 여러가지 Box Style@Preview(showBackground = true)@Composableprivate fun BoxSample() { Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(4.dp)) { Box( modifier = Modifier .clip(CircleShape) .background(Color.Red) .size(44.dp) ) Box( modifier = Modifier .size(44... 2024. 6. 3.