여기서 볼 수있는 "Google I/O 2012 - 더 안 좋은 것을하는 좋은 Android 시민"이야기 듣기 http://www.youtube.com/watch?v=gbQb1PVjfqM&list=PL4C6BCDE45E05F49E&index=10&feature=plpp_video api 레벨 14부터 onTrimMemory
을 무시할 수 있다는 것을 알았습니다. 메모리 사용량을 줄이는 것과 같은 일을하고 싶습니다. 하지만 내 CursorAdapter 인스턴스 내에서 내 Activity 외부에 ComponentCallbacks2 인터페이스를 구현하고 싶습니다. 이 대화에서 : Context.registerComponentCallbacks()
을 사용합니다. 그러나 이것을 사용하려고하면 입력 매개 변수가 필요합니다. mContext.registerComponentCallbacks(ComponentCallbacks callbacks);
android onTrimMemory and ComponentCallbacks2
어떻게 사용할 수 있습니까?
지금은 결코 호출되지 도착이
public class ContactItemAdapter extends ResourceCursorAdapter implements ComponentCallbacks2{
... ...
@Override
public void onTrimMemory(int level) {
Log.v(TAG, "onTrimMemory() with level=" + level);
// Memory we can release here will help overall system performance, and
// make us a smaller target as the system looks for memory
if (level >= TRIM_MEMORY_MODERATE) { // 60
// Nearing middle of list of cached background apps; evict our
// entire thumbnail cache
Log.v(TAG, "evicting entire thumbnail cache");
mCache.evictAll();
} else if (level >= TRIM_MEMORY_BACKGROUND) { // 40
// Entering list of cached background apps; evict oldest half of our
// thumbnail cache
Log.v(TAG, "evicting oldest half of thumbnail cache");
mCache.trimToSize(mCache.size()/2);
}
}
}
하지만 onTrimMemory
을 사용하고 있습니다.
이 개체의 mCache는 –