我正在使用Glide库来显示图片。我正在尝试使用以下代码清除Glide缓存:
Glide.get(MainActivity.this).clearDiskCache();
Glide.get(MainActivity.this).clearMemory();
以上代码在Async中,我在Do background部分调用它。
当我运行此代码时,总是出现:
Caused by: java.lang.IllegalArgumentException: You must call this method on the main thread
at com.bumptech.glide.util.Util.assertMainThread(Util.java:135)
at com.bumptech.glide.Glide.clearMemory(Glide.java:370)
这里可能出了什么问题?如果我在MainThread中使用上述代码,它会要求在后台运行。
我该如何清除缓存?
谢谢!
onPostExecute()
中执行Glide.get(MainActivity.this).clearMemory();
吗? - Much Overflow