[로그]
12-12 11:59:09.025: E/AndroidRuntime(6603): FATAL EXCEPTION: main
12-12 11:59:09.025: E/AndroidRuntime(6603): android.database.StaleDataException: Attempted to access a cursor after it has been closed.
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.database.BulkCursorToCursorAdaptor.throwIfCursorIsClosed(BulkCursorToCursorAdaptor.java:75)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.database.BulkCursorToCursorAdaptor.requery(BulkCursorToCursorAdaptor.java:144)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.database.CursorWrapper.requery(CursorWrapper.java:186)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.app.Activity.performRestart(Activity.java:4510)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.app.ActivityThread.handleSleeping(ActivityThread.java:2952)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.app.ActivityThread.access$2600(ActivityThread.java:127)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1279)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.os.Looper.loop(Looper.java:137)
12-12 11:59:09.025: E/AndroidRuntime(6603): at android.app.ActivityThread.main(ActivityThread.java:4511)
12-12 11:59:09.025: E/AndroidRuntime(6603): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 11:59:09.025: E/AndroidRuntime(6603): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 11:59:09.025: E/AndroidRuntime(6603): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:986)
12-12 11:59:09.025: E/AndroidRuntime(6603): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:753)
12-12 11:59:09.025: E/AndroidRuntime(6603): at dalvik.system.NativeStart.main(Native Method)
[소스]
RingtoneManager ringtoneMgr = new RingtoneManager(mContext);
ringtoneMgr.setType(RingtoneManager.TYPE_ALARM);
Cursor alarmsCursor = ringtoneMgr.getCursor();
if(alarmsCursor != null){
int alarmsCount = alarmsCursor.getCount();
if(alarmsCount < 0){
alarmsCursor.close();
alarmsCursor = null;
return;
}
RingtoneManager의 getCursor 사용 후 Activity가 onResume 될때 아래의 Exception이 발생한다.
원인은 cursor를 close 하는데서 발생한다.
일반적인 Cursor는 당연히 close해야 하는 것이 정상이지만
RingtoneManager getCursor를 통해 가져온 Cursor 는 close 하지 말란다...
public Cursor getCursor ()Added in API level 1 Returns a RingtoneManager(Activity) was not used, the caller should manage the returned cursor through its activity's life cycle to prevent leaking the cursor. |
참고 : http://developer.android.com/reference/android/media/RingtoneManager.html#getCursor()
'programmer > android' 카테고리의 다른 글
Toast 팝업 (0) | 2012.12.13 |
---|---|
EditText bottom space (0) | 2012.12.13 |
Battery check (0) | 2012.10.19 |
이클립스 환경 설정 (1) | 2012.09.22 |
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. (0) | 2011.11.28 |