강의

멘토링

커뮤니티

Inflearn Community Q&A

woo9411026142's profile image
woo9411026142

asked

[Intermediate] Creating a Coin Price Monitoring App (Android Kotlin)

Event handling after device reboot (Receiver)

BroadcastReceiver가 안됩니다ㅠㅠ

Written on

·

500

·

Edited

0

BootReceiver의 용도가 전원을 껏다가 켜도 상단바에 알림이 뜨게끔 하는 용도라고 알고있는데 적용이 되지 않습니다 ㅠㅠ 로그는 저렇게 뜨네요 ㅠㅠ

 

개복치님 코드로도 실행이 안되는데 제 에뮬과 실기기가 이상한걸까요 ㅠㅠㅠㅠ????

 

<uses-permission android:name="android.permission.RECEIV<receiver 

android:name=".receiver.BootReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>E_BOOT_COMPLETED"/>
class BootReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {

        Timber.d("onReceive")
        Timber.d(intent?.action)
        if(intent?.action.equals("android.intent.action.BOOT_COMPLETED")){
            val foreground = Intent(context, PriceForgroundService::class.java)
            foreground.action = "START"

            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
                context?.startForegroundService(foreground)
            }else{
                context?.startService(foreground)
            }
        }
    }
}

 

androidkotlin

Answer 1

1

woo941102님의 프로필 이미지
woo941102
Questioner

해결했습니다! 에뮬레이터 및 실디바이스 재부팅 후 한 3-5분 정도 기다려야 나오네요! 제가 성격이 급했나봅니다. 해결했어요!

bokchi님의 프로필 이미지
bokchi
Instructor

해결하셨다니 다행입니다 :)

woo9411026142's profile image
woo9411026142

asked

Ask a question