diff options
author | Marcos Marado <mmarado@cyngn.com> | 2016-04-14 15:41:42 +0100 |
---|---|---|
committer | Marcos Marado <mmarado@cyngn.com> | 2016-04-14 15:43:22 +0100 |
commit | 95d19347d6f6f20658f29286c7e3ce81e97d9b97 (patch) | |
tree | f6b27f042a5a8bccd992fd1c3ffdf81702e0681a /src/com/android/launcher3 | |
parent | 5e5f8259c31ce5c628922f0ce0760df6704856bb (diff) | |
download | android_packages_apps_Trebuchet-95d19347d6f6f20658f29286c7e3ce81e97d9b97.tar.gz android_packages_apps_Trebuchet-95d19347d6f6f20658f29286c7e3ce81e97d9b97.tar.bz2 android_packages_apps_Trebuchet-95d19347d6f6f20658f29286c7e3ce81e97d9b97.zip |
avoid NPE
Change-Id: I8a2d74c8c305112fcbb76d56b126d15a6015de8b
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index 05184cf0e..bdb5c5bf1 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -547,23 +547,29 @@ public class LauncherProvider extends ContentProvider { // Database was just created, so wipe any previous widgets if (mAppWidgetHost != null) { - mAppWidgetHost.deleteHost(); - - /** - * Send notification that we've deleted the {@link AppWidgetHost}, - * probably as part of the initial database creation. The receiver may - * want to re-call {@link AppWidgetHost#startListening()} to ensure - * callbacks are correctly set. - */ - new MainThreadExecutor().execute(new Runnable() { - - @Override - public void run() { - if (mListener != null) { - mListener.onAppWidgetHostReset(); + try { + mAppWidgetHost.deleteHost(); + /** + * Send notification that we've deleted the {@link AppWidgetHost}, + * probably as part of the initial database creation. The receiver may + * want to re-call {@link AppWidgetHost#startListening()} to ensure + * callbacks are correctly set. + */ + new MainThreadExecutor().execute(new Runnable() { + + @Override + public void run() { + if (mListener != null) { + mListener.onAppWidgetHostReset(); + } } - } - }); + }); + } catch (NullPointerException ex) { + // nothing to do here. Why did this pass the null check? I don't know. but this fixes it. + // (avoids: Caused by: java.lang.NullPointerException: Attempt to invoke interface method + // 'void com.android.internal.appwidget.IAppWidgetService.deleteHost(java.lang.String, int)' + // on a null object reference + } } // Fresh and clean launcher DB. |