android

Fragment에서 권한 요청하기 (2021)

Activity Result를 받아오는 API가 변경되면서 Fragment.requestPermissions도 deprecated 되었다. registerForActivityResult를 호출하고 ActivityResultContracts.RequestPermission을 인자로 전달해야한다. 복수의 권한이 필요한 경우는 Contract를 RequestMultiplePermissions로 바꿔서 사용한다. 하지만 사진/동영상 촬영, 연락처 선택 등 일반적인 케이스는 기본적으로 제공하는 Contract를 활용하는 것으로 커버할 수 있다.

Fragment에서 권한 요청하기 (2021) Read More »

[Kotlin] for-loop with no additional object allocation

In Kotlin, we can use functions such as forEach, forEachIndexed, and map to iterate items in collection. It’s convenient to use, but it comes with cost; those functions create additional objects like Iterator. For most cases, it wouldn’t be a serious problem to have some temporary objects. However, when overriding onDraw method of View class,

[Kotlin] for-loop with no additional object allocation Read More »

Deprecated or Experimental

안드로이드 API는 큰 흐름상으로는 바람직하게 가고는 있지만 여전히 불만인 부분은 마음놓고 쓰기가 어렵다는 점이다. 어느 정도 안정화되고 손에 익었다 싶으면 deprecated되고 또 새로운 게 나오는데 새로운 걸 쓰려면 모험을 해야한다. 예전 API를 계속 쓰자니 찝찝하고, 새로운 걸 쓰자니 불안하고. 이런 스트레스를 항상 안고 개발해야하는 게 좀 불만이다.

Deprecated or Experimental Read More »

[Kotlin] 객체 할당 없는 for loop

Kotlin에서는 배열이나 컬렉션을 다룰 때 forEach, forEachIndexed, map 등을 통해 내부 항목들을 접근해서 연산을 수행할 수 있다. 이러한 함수들은 인덱스를 직접 관리할 필요가 없어서 편리하긴 하지만, Range나 Iterator같은 부가적인 객체를 생성한다는 단점이 있다. 대부분의 경우에는 객체 한두개 정도 추가 할당하는 것이 큰 문제가 되지 않겠지만, 안드로이드에서 View 클래스의 onDraw 메서드를 오버라이드할 때에는 메서드 내에서 새로운

[Kotlin] 객체 할당 없는 for loop Read More »

Check App Standby Bucket using ADB command

A new power management feature called App Standby Bucket has beed added in Android 9(Pie).(https://developer.android.com/about/versions/pie/power) App Standby Bucket allows Android system to categorize priorities of apps in 5 buckets as follows; Active Working set Frequent Rare Never Apps go into one of those buckets according to how actively they are used. An important thing to

Check App Standby Bucket using ADB command Read More »

ADB로 App Standby Bucket 확인하기

안드로이드 9부터는 App Standby Bucket이라는 전원 관리 기능이 추가되었다.(https://developer.android.com/about/versions/pie/power) App Standby Bucket이란 안드로이드 시스템이 앱을 처리하는 우선순위를 아래와 같이 크게 다섯 가지로 분류하는 기능이다. Active Working set Frequent Rare Never 사용자가 앱을 얼마나 자주 사용하는지에 따라 각 버킷으로 이동하게 되며 정확한 기준은 (어뷰징을 생각한다면 당연히) 알려져있지 않다. 한 가지 주의할 부분은 앱이 어느 버킷에 있느냐에

ADB로 App Standby Bucket 확인하기 Read More »