동적 브로드캐스트리시버 자동 해지 auto-unregister broadcast receiver that has been registered dynamically
yo bro~
fu@ckup english!!!!!! that bitch too hard to read
why the fucking english is all over this "Hello, World!"
besides, android api guides has not been translated completely!!!!!!!
what the fuck!
why do the fucking computer dudes get us, ching-chang-chong, hard to study it
jsaofjseoifjaoij1o2j31
동적으로 브로드캐스트 리시버를 등록하면 그것은 메모리 릭을 유발합니다.
그러므로 해당 어플리케이션 또는 작업이 더이상 유효하지 않을때 해당 브로드캐스트 리시버를 해지해주어야 합니다.
그런데 일일히 하기도 그렇고... instrumentation같은 경우에는 종료할때 발생되는 method가 없음
그러므로 알아서 timeout 하는 브로드캐스트 리시버를 만들었음.
그냥 시간가져와서 비교후에 거시기 함. 알아서 쓰도록.
public class BC extends BroadcastReceiver { private static final long AUTO_UNREGISTER_TIME_OUT = 10000; private long m_last_received; public BC() { super(); m_last_received = new Date().getTime(); } @Override public void onReceive(Context context, Intent intent) { long time_out; long now; now = new Date().getTime(); //get time out and determine whether to unregister or to update m_last_received time_out = now - m_last_received; if(time_out >= (AUTO_UNREGISTER_TIME_OUT)) { //unregister context.unregisterReceiver(this); } else { //update m_last_received m_last_received = now; } } }
'Android' 카테고리의 다른 글
Windows 10 안드로이드 스튜디오 한글 깨짐 (0) | 2016.07.18 |
---|---|
안드로이드 스마트폰을 프록시 서버로 쓰기 (0) | 2016.03.02 |
붙여넣기 키코드 paste keycode (3) | 2016.01.21 |
PC(C#)와 Android App 통신 using madb (0) | 2015.09.10 |
adb 비행기 모드 on off (0) | 2015.09.10 |