Tôi có Hoạt động chính A sử dụng CursorLoader để truy vấn DB. Này tôi tạo ra trong hoạt động onCreate() phương pháp:Tại sao CursorLoader onLoaderReset() được gọi sau khi xoay thiết bị?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
getSupportLoaderManager().initLoader(LOADER_MEASUREMENTS, null, A.this);
}
Hoạt động A cũng thực hiện 3 callbacks cho CursorLoader:
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args)
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor)
public void onLoaderReset(Loader<Cursor> loader)
Khi tôi xoay điện thoại, tôi thấy phương pháp vòng đời đúng chạy:
A.onPause()
A.onStop()
A.onDestroy()
A.onCreate() <-- re-connect to existing loader, onCreateLoader() not called
A.onLoadFinished()
A.onStart()
A.onResume()
Sau đó, tôi mở một hoạt động phụ B và xoay thiết bị của tôi. Khi tôi kết thúc B và quay lại Hoạt động A, tôi thấy hoạt động sau:
B.onPause()
A.onLoaderReset() <- why does this run?
A.onDestroy()
A.onCreate()
A.onCreateLoader() <- now runs as loader is null
A.onStart()
...
Tại sao bộ nạp của tôi được đặt lại vì tôi đã kích hoạt Hoạt động B và xoay thiết bị? Chỉ cần thêm Activity B đó không liên quan gì đến DB hoặc CursorLoader.
[Câu hỏi này] (http://stackoverflow.com/questions/15897547/loader-unable-to-retain-itself-during-certain-configuration-change?lq=1) và các câu hỏi được liên kết có liên quan. Có lẽ bạn có thể tìm thấy một cái gì đó có thể giúp đỡ. –
Cảm ơn George - câu hỏi đó thảo luận chính xác cùng một vấn đề tôi đang gặp phải. Có vẻ như nó có thể là do Trình quản lý tải hỗ trợ. – MickeyR
[link] này (https://code.google.com/p/android/issues/detail?id=183783) nói rằng điều này là/sẽ được sửa trong v24. – MickeyR