Null check for create event dialog fragment
Bug: 8777939
Change-Id: I9759d2c760c1d54ff3a4ce0007c2aea3fe6ed8f0
diff --git a/src/com/android/calendar/event/CreateEventDialogFragment.java b/src/com/android/calendar/event/CreateEventDialogFragment.java
index 5eb69a1..0381b30 100644
--- a/src/com/android/calendar/event/CreateEventDialogFragment.java
+++ b/src/com/android/calendar/event/CreateEventDialogFragment.java
@@ -31,6 +31,7 @@
import android.text.TextWatcher;
import android.text.format.DateUtils;
import android.text.format.Time;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -52,6 +53,8 @@
*/
public class CreateEventDialogFragment extends DialogFragment implements TextWatcher {
+ private static final String TAG = "CreateEventDialogFragment";
+
private static final int TOKEN_CALENDARS = 1 << 3;
private static final String KEY_DATE_STRING = "date_string";
@@ -261,8 +264,15 @@
return;
}
- String defaultCalendar = Utils.getSharedPreference(
- getActivity(), GeneralPreferences.KEY_DEFAULT_CALENDAR, (String) null);
+
+ String defaultCalendar = null;
+ final Activity activity = getActivity();
+ if (activity != null) {
+ defaultCalendar = Utils.getSharedPreference(activity,
+ GeneralPreferences.KEY_DEFAULT_CALENDAR, (String) null);
+ } else {
+ Log.e(TAG, "Activity is null, cannot load default calendar");
+ }
int calendarOwnerIndex = cursor.getColumnIndexOrThrow(Calendars.OWNER_ACCOUNT);
int accountNameIndex = cursor.getColumnIndexOrThrow(Calendars.ACCOUNT_NAME);