diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index ff6d79604..e52b93000 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -6,6 +6,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.AsyncTask +import android.os.Build import android.os.Bundle import android.os.Handler import android.provider.MediaStore @@ -360,6 +361,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun checkLastMediaChanged() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed) + return + mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.postDelayed({ Thread({ diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 16d166fa2..804624b06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -5,6 +5,7 @@ import android.app.WallpaperManager import android.content.Intent import android.graphics.Bitmap import android.net.Uri +import android.os.Build import android.os.Bundle import android.os.Handler import android.support.v7.widget.GridLayoutManager @@ -133,6 +134,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun checkLastMediaChanged() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed) + return + mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.postDelayed({ Thread({