Tech

BroadcastReceiver 사용 시 유의점

BroadcastReceiver는 onReceive가 처리되는 동안만 존재한다. 즉, onReceive()가 처리되는 도중에 또다시 같은 인스턴스의 onReceive()가 호출되지는 않는다. 매번 새로운 인스턴스가 생성된다. 비동기처리를 통해 결과를 가져오는 작업을 못함 비동기처리가 진행되는 도중 onReceive가 리턴하고나면 BroadcastReceiver 인스턴스는 이미 invalid 상태 API 11부터는 goAsync()를 통해 가능하긴 하다. PendingResult를 가지고 있다가 다 완료되면 PendingResult.finish()를 호출해서 종료 다이얼로그 같은 거 못 띄움 NotificationManager …

BroadcastReceiver 사용 시 유의점 Read More »

Python에서 sqlite로 파일경로 insert 시 인코딩 에러

sqlite3 데이터베이스에 파일 경로를 삽입하니 아래와 같은 에러가 발생했다. sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. 문자열을 아래와 같이 utf-8로 디코딩하면 해결된다. ‘path_to_somewhere’.decode(‘utf-8’)  

adb를 통해서 임의의 인텐트 시작하기

커스텀 URL을 처리하거나 기타 암묵적(implicit) 인텐트를 처리하는 기능을 구현할 때 adb를 통해서 인텐트를 발생시키면 편리하게 테스트할 수 있다. 아래와 같은 형식으로 실행하면 된다. adb shell am start -a <action> -d <data> 예시 adb shell am start -a android.intent.action.VIEW -d http://www.example.com