본문 바로가기

안드로이드 background/Foreground /** * Created by skchoi on 2020/03/27 * * ForegroundCheck.get().isBackground * ForegroundCheck.get().appStatus * * 간단한 동작 설명 * onActivityStarted 추가 되면 카운트 +1 * onActivityStopped 추가 되면 카운트 -1 * 카운트가 0 이면 백그라운드 * 카운트가 1 보다 크면 포그라운드 * 카운트가 1 이면 포그라운드 전환 */ import android.app.Activity; import android.app.Application; import android.os.Bundle; public class ForegroundCheck implements Application.Activ.. 더보기
람다와 함수형 인터페이스(약속된 Lambda interface) 람다와 함수형 인터페이스 Supplier -> R get() 같은 역할을 한다.(int를 반환 하는 메소드 처럼 씀) Consumer -> void accept(T t) 메소드와 같은 역할을 한다.(param을 받아서 소모하는 메소드 처럼 씀) Predicate -> boolean test(T t) true, false 조건 판단이 필요할 때 역할을 맡는다.. UnaryOperator -> Integer func(Integer param) 매개변수와 리턴 타입이 동일할 때의 역할을 맡는다. Long이든 Double든 unary는 단항을 의미 Operator은 연산 Function -> R apply(T t) T를 인자로 받아서 R을 리턴해 주는 보통 정의되는 메소드 역할을 맡는다. IntFuction 전.. 더보기
Broadcast -> LocalBroadcast로 변환하기 sendBroadcast(new Intent(Const.ACTION_RELOAD_FAVORITE)); 같이 기존에 Broadcast를 날리던 코드는 안드로이드 시스템 전체에 방송을 때리기 때문에 자신의 앱에만 방송을 날리도록 코드를 수정한다. LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(new Intent(Const.ACTION_RELOAD_FAVORITE)); 더보기
AAPT2 error: check logs for details AAPT2 error: check logs for details 현재 안드로이드 스튜디오 3.3.1을 쓰고 있는데 run시 에러가 발생해서 구글링해봐도 프로젝트 내에 gradle.properties 파일을 열고 수정해 주라는 글만 있었다. android.enableAapt2=false 그런데 2018년도 까지만 쓸 수 있는 거다. 이러면서 문제 해결이 되지 않았다. 프로젝트 build.gradle 내에 gradle버전을 올려주고 dependencies { classpath 'com.android.tools.build:gradle:3.3.2' // NOTE: Do not place your application dependencies here; they belong // in the individual m.. 더보기
appbar_scrolling_view_behavior not found. 에러 책 예제를 따라치던 중 이런 에러가 발생했다. error: attribute 'com.zxcv5500.toyproject:contentScrim' not found. error: attribute 'com.zxcv5500.toyproject:layout_scrollFlags' not found. error: attribute 'com.zxcv5500.toyproject:layout_collapseMode' not found. error: resource string/appbar_scrolling_view_behavior (aka com.zxcv5500.toyproject:string/appbar_scrolling_view_behavior) not found. 에러가 나는 원인은 사용하는 라이브러리를 ap.. 더보기