• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

BroadcastReceiver가 안됩니다ㅠㅠ

23.10.01 01:52 작성 23.10.01 13:34 수정 조회수 241

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)
            }
        }
    }
}

 

답변 1

답변을 작성해보세요.

1

woo941102님의 프로필

woo941102

질문자

2023.10.01

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

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