본문 바로가기

Android52

[Android] Java 클래스에서 Kotlin static 함수를 불러올 때, Non-static method cannot be referenced from a static context 에러 현상 경로:Java 클래스에서 Object 클래스 함수를 불러오려고 하는데, 기존에 불러오던 것 처럼 불러오니 불러오지 못하는 현상이 발생했다.Assert.equals(ParticipantData.DEFAULT_SELF_SUB_ID, subId); 컴파일 에러 발생Non-static method cannot be referenced from a static context   문제의 원인:정적 함수에서 비정적 메서드를 호출하려고 할 때 발생하는데, Assert.equals 메서드는 비정적 함수기 때문에 정적 컨텍스트에서 호출할 수 없다.  해결 방법:Kotlin에서 싱글톤 객체는 자동으로 INSTANCE 필드를 생성하기 때문에 정적 컨텍스트에서 접근할 수 있도록 한다.Assert.INSTANCE.equal.. 2024. 6. 26.
[Android] Framework의 core에 리소스를 추가했으나 불러오지 못하는 현상 SystemUI의 GlobalActionsDialogLite 작업 중 core의 res에 drawable과 string을 추가했으나, 해당 리소스를 불러오지 못하고 빌드 에러가 발생하는 현상을 발견했다. SystemUI는 기본적으로 core의 리소스를 불러와 사용하기 때문에,import com.android.internal.R;packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java - platform/frameworks/base - Git at Googlestring과 drawable을 core 쪽에 추가해 구현했다. 분명 이전 버전 작업(Android 9 ~ 12)과 동일하게 작업했음에도 불구하고, 계속 .. 2024. 6. 24.
[Android] 유선 이어폰 연결 감지 하기 브로드 캐스트 리시버 등록IntentFilter filter = new IntentFilter();filter.addAction(ACTION_HEADSET_PLUG);registerReceiver(receiver, filter);ACTION_HEADSET_PLUG를 등록 브로드 캐스트 리시버 생성private final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(ACTION_HEADSET_PLUG)){ int state = intent.ge.. 2024. 6. 5.
[Android] Android 12 기준 블루투스 연결 감지하기 Android 12에서 블루투스 연결 감지 권한 블루투스 권한  |  Connectivity  |  Android Developers이 페이지는 Cloud Translation API를 통해 번역되었습니다. 블루투스 권한 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 앱에서 블루투스 기능을 사용하려면 여developer.android.com권한을 추가해 주고사용자에게 권한을 받아야 한다.if(checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED){ requestPermissions(new String[]{Manifest.permission.BLUETO.. 2024. 6. 5.