Merged
Conversation
- NetworkChangeReceiver: 네트워크 연결 상태가 변경될 때 호출되는 BroadcastReceiver - NetworkActivity: 네트워크 연결 상태에 따라 UI를 업데이트하는 Activity
- `NetworkChangeReceiver` 의 네트워크 상태 로직을 액티비티로 옮긴다
- `AlarmActivity` 추가: 6초 후 알림을 예약하고 표시한다 - `POST_NOTIFICATIONS` 권한 요청 (API 33 이상) - `SCHEDULE_EXACT_ALARM` 권한 확인 및 요청 (API 31 이상) - `AlarmManager.setExact()`를 사용하여 특정 시간에 알림 예약 - `NotificationReceiver` 추가: 예약된 알림을 수신하여 사용자에게 알림 표시 - `AndroidManifest.xml`에 `AlarmActivity`, `NotificationReceiver`, `SCHEDULE_EXACT_ALARM` 권한 추가
- `onReceive` 메서드에서 알림 생성 및 표시 로직을 별도 함수로 분리 - 불필요한 로그 호출 제거 - `android.R` 대신 `R` 사용하도록 수정
- 브로드캐스트 리시버의 개념, 사용 사례, 종류 설명 - 동적 등록 예시: 네트워크 상태 변경 감지 - `NetworkChangeReceiver`, `NetworkActivity` 코드와 함께 동작 순서, 플랫폼 아키텍처에서의 동작 흐름 설명 - 정적 등록 예시: 자동 알림 - 주요 컴포넌트(`AlarmManager`, `PendingIntent`, `BroadcastReceiver`, `NotificationManager`) 역할 소개 - `AlarmActivity`, `NotificationReceiver` 코드와 함께 동작 순서, 플랫폼 아키텍처에서의 동작 흐름 설명
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
주요 실습
1. 네트워크 상태 변화 감지 기능 구현(동적으로 Broadcast 등록)
BroadcastReceiver(NetworkChangeReceiver)를 동적으로 등록하여, 네트워크 상태 변경 브로드캐스트 수신NetworkActivity로 이동하여 책임 분리2. 알람 기반 푸시 알림 기능 구현(정적으로 Broadcast 를 Manifest 등록)
AlarmActivity에서 버튼 클릭 시AlarmManager.setExact()을 사용해 6초 후 알림 예약NotificationReceiver의onReceive()에서 Notification 표시AlarmActivity가 실행되도록PendingIntent구성이후 BroadcastReceiver 실습 방향 (TODO)
1. 정적 등록이 가능한 브로드캐스트 목록 추가 학습
BOOT_COMPLETED,SMS_RECEIVED,ACTION_PACKAGE_ADDED등2. 브로드캐스트 우선순위(priority) 및 순차 처리(ordered broadcast)
intent-filter에 설정 가능한<priority>속성abortBroadcast()의 의미와 실제 사용 사례3. 보안 관점에서의 BroadcastReceiver
android:permission,LocalBroadcastManager비교4. BroadcastReceiver vs WorkManager / NetworkCallback