diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index 4521e64a1..662dbd17c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -89,7 +89,7 @@ class WidgetConfigureActivity : SimpleActivity() { private fun saveConfig() { val views = RemoteViews(packageName, R.layout.widget) views.setBackgroundColor(R.id.widget_holder, mBgColor) - AppWidgetManager.getInstance(this).updateAppWidget(mWidgetId, views) + AppWidgetManager.getInstance(this)?.updateAppWidget(mWidgetId, views) ?: return config.showWidgetFolderName = folder_picker_show_folder_name.isChecked val widget = Widget(null, mWidgetId, mFolderPath) ensureBackgroundThread { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 771aa8ee3..cd120112d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -818,7 +818,7 @@ fun Context.deleteMediumWithPath(path: String) { } fun Context.updateWidgets() { - val widgetIDs = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetProvider::class.java)) + val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetProvider::class.java)) ?: return if (widgetIDs.isNotEmpty()) { Intent(applicationContext, MyWidgetProvider::class.java).apply { action = AppWidgetManager.ACTION_APPWIDGET_UPDATE