Activity unregister / Leaked IntentReceiver issue

2013. 5. 9. 23:36·Android Development
반응형

refer to 

http://stackoverflow.com/questions/3577566/android-leaked-intentreceiver-exception-is-being-thrown-even-though-i-call-unre


This is a Android activity life cycle issue. I am seeing it in a main activity and then testing on device with the back button that goes back to a splash screen.

In the onPause() method.

Unregister the Broadcast Receiver that you created in the onCreate()

In the onRestart() re-register a brand new Broadcast Receiver.

In the activity class you need to keep a record of the Broadcast Receiver as instance data member.

SECOND

I think this also a feature enhancement issue with Android.

Sometimes developer need a broadcast receiver to outlive the activity. For example to understand when certain screen states are available or not. Think about a conversation context of work flow model, which has many states.

THIRD

You can register and unregister broadcast receivers with an activity, but a simple call like isRegistered(BroadcastReceiver) in the Activity class might be very useful.

If you need receivers to live beyond the activity, then I do not the answer, except to silence the warning, by adding unregister(X) in the onDestroy() call. YMMV ;-)

저작자표시 비영리 변경금지 (새창열림)

'Android Development' 카테고리의 다른 글

SQLiteOpenHelper Singleton instance creating.  (0) 2013.07.04
ndk-stack 으로 so 파일 debugging 하기  (0) 2013.05.13
NFC Guide  (0) 2013.05.08
DDMS thread dump  (0) 2013.03.30
ID3 TAG Parsing & Saving  (0) 2013.03.26
'Android Development' 카테고리의 다른 글
  • SQLiteOpenHelper Singleton instance creating.
  • ndk-stack 으로 so 파일 debugging 하기
  • NFC Guide
  • DDMS thread dump
fogthegreat
fogthegreat
아주 오랫동안 이것 저것 개발하면서 배우고 찾아 본 것들을 적거나 모았습니다. 불편한 점이 있다면 알려주세요. (과거에 불펌한 글들을 모두 제거하고 있는 중이에요. 🙏)
  • fogthegreat
    꿈소년의 개발 이야기
    fogthegreat
  • 전체
    오늘
    어제
    • 전체보기 (242)
      • Software Engineering (56)
      • Android Development (78)
      • 일상다반사 (63)
      • 책에 대한 거의 모든 것 (11)
      • 영어공부 (1)
      • ETC (0)
      • 챌린지 (1)
      • Do it 스터디! (32)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

    • 향로
    • 청하가 제안하는 소프트웨어 엔지니어로써 재미있게 사는 …
    • WhoRU? Story...♡
    • Snapshot
    • 두잇! - 이지스퍼블리싱
    • 제이펍의 참 똑똑한 2비트 책 이야기
    • Inpa Dev
  • 공지사항

  • 인기 글

  • 태그

    Eclipse
    linux
    노개북
    kotlin
    안드로이드
    css
    build.gradle
    java
    안드로이드 개발
    JavaScript
    탐지기법
    리눅스
    html
    js
    보안
    git
    코틀린
    Android
    google
    C++
    Android 4.1
    구글
    gradle
    ActiveX
    안철수
    OOM
    hcj
    개발
    자바
    하버드
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
fogthegreat
Activity unregister / Leaked IntentReceiver issue
상단으로

티스토리툴바