본문 바로가기

IT/Android

(48)
android / fcm notification (background data 컨트롤, 다국어 대응) 1. background data 컨트롤 fcm notification은 다음과 같은 형태로 값을 보낸다.{ "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification":{ "title":"Portugal vs. Denmark", "body":"great match!" }, "data" : { "Nick" : "Mario", "Room" : "PortugalVSDenmark" } }} notification과 data키가 있다.foreground 상태에서 해당 푸시를 받으면 onMessageRecieved함수에서 data값 및 푸시 알림을 컨트롤 할 ..
Android / 키해시 구하기 keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android | openssl sha1 -binary | openssl base64 안드로이드 스튜디오 터미널에 입력
Android / Version Catalog 적용 - 안드로이드 버전관리 1. gradle/libs.versions.toml 파일 생성[versions]coreKtx = "1.9.0"androidApplication = "8.1.0"[libraries]core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }[plugins]android-application = { id = "com.android.application", version.ref = "androidApplication" } 2. app/build.gradle.kt 에 적용implementation(libs.core.ktx) 3. build.gradle.kt에 적용plugins { alias(libs.plugins.and..
Android version 맞추기 (targetSdk 34 업그레이드/kotlin 버전 업그레이드) 1. 라이브러리 모듈과 프로젝트의 코틀린 버전의 충돌이 남. Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. 1. targetSdk를 34로 업그레이드 하고(내친김에), 코틀린 버전을 1.8.0으로 올림 targetSdk 33 -> 34 compileSdk 33 -> 34 'com.android.tools.build:gradle:7.2.1' -> 'com.android.tools.build:gradle:7.2.2' 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' -> 'org...
Compose / 밀어서 삭제 구현 SwipeToDismiss 사용하기 Compose SwipeToDismiss를 사용하면 밀어서 삭제를 간단하게 구현할 수 있다. LazyColumn(modifier = Modifier.fillMaxHeight()) { items( items = tempList, key = { temp -> temp.no} ) { item -> val currentItem by rememberUpdatedState(newValue = item) SwipeToDismiss( state = rememberDismissState(confirmStateChange = { if(it == DismissValue.DismissedToStart){ // 밀었을때 액션 } true }), directions = setOf(DismissDirection.EndToStart..
Android / 안드로이드 notification Icon 적용 안드로이드 푸시메세지를 받았을때 뜨는 notification의 icon은 svg, 흰색, 24dp
Android / 푸시알림 클릭시 PendingIntent Bundle값 전달 안되는 경우 푸시 알림 클릭하면 PendingIntent를 이용하여 MainActivity로 이동하는 로직에서 intent로 전달된 Bundle값이 초기값으로만 이동되는 현상이 발생하였다. 반복적으로 푸시알림이 들어와 노티가 쌓이게 되면 bundle값이 캐싱되어 실시간으로 값 변동이 전달되지 않는다. public static PendingIntent getActivity(Context context, int requestCode, @NonNull Intent intent, int flags, @Nullable Bundle options) { throw new RuntimeException("Stub!"); } PendingIntent.getActivity 함수를 보면 requestCode를 인자로 받고있다. 해당 인..
Compose / LazyClumn items 리컴포지션 일어나지 않는 경우 (상태변화 감지 안됨) items에 넣은 List의 해시값이 변해도 이미 그려놓은 리스트는 해시값이 변경된걸 모른다. 리컴포지션일 일어나게 하기 위해서는 items에 key값을 지정해줘서, 리스트가 변경될때 키값 변경이 감지되도록 해야한다. items 함수를 살펴보자. inline fun LazyListScope.items( items: List, noinline key: ((item: T) -> Any)? = null, noinline contentType: (item: T) -> Any? = { null }, crossinline itemContent: @Composable LazyItemScope.(item: T) -> Unit ) = items( count = items.size, key = if (key != null..

반응형