본문 바로가기

IT

(71)
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..
android / 안드로이드 webview에서 window.popup() 띄우기 웹뷰에서 window.popup()으로 새 창을 띄우는 코드가 있었는데, 안드로이드 앱에서는 새 창이 안뜨는 현상이 발견됐다. window.popup() 으로 새 창이 뜨면, 안드로이드 내에서 dialog가 뜨게 하여 새로운 webview를 띄우는 방법으로 해결했다. popup이 뜨는 것을 감지하는 곳은 webChromClient의 onCreateWindow였다. <pre id="code..
android / 안드로이드 webview history back 화면 스크롤 유지 방법 (activity 이동) 안드로이드에서 띄운 webview에서 history back을 하면 전 화면으로 돌아가면서 refresh가 되는 현상이 생겼다. 스크롤을 내렸다가 다음 화면으로 넘어가고 뒤로 돌아왔을때, 화면이 새로고침 되어 스크롤 유지가 안됐다. 화면이 이동돼도, 이전 화면을 유지시키고 싶기 때문에 특정 화면 이동시 새로운 액티비티를 띄우고, 뒤로 갈때는 새로운 액티비티를 finish 하는 방법을 선택했다. 1. 다음 화면으로 넘어갈때 새로운 Activity를 만들어 Intent로 페이지 이동 override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { Util.logMessage("shoudOverrideUrlLoading ==> $url"..

반응형