From ff213cdd08e445b55bca4cc4577fbec45a7ef551 Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Wed, 10 Jun 2015 14:51:08 -0700 Subject: Keep a local instance of mContactData when copying to SIM card. Copying to SIM card can take a long time while it reads data about available space on the SIM. If the user leaves the activity, mContactData will be set to null and copyToCard will throw an NPE trying to call methods on it. Keep a local instance of this variable that the thread can reference later. Change-Id: Ie5187372b6fb2b23b00e266a175c91b8051e651e --- src/com/android/contacts/quickcontact/QuickContactActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java index 90a7fd6ff..d4cae72bf 100644 --- a/src/com/android/contacts/quickcontact/QuickContactActivity.java +++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java @@ -2750,6 +2750,7 @@ public class QuickContactActivity extends ContactsActivity { private Handler mHandler = null; private void copyToCard(final int sub) { + final Contact contactData = mContactData; final int MSG_COPY_DONE = 0; final int MSG_COPY_FAILURE = 1; final int MSG_CARD_NO_SPACE = 2; @@ -2835,12 +2836,12 @@ public class QuickContactActivity extends ContactsActivity { int emptyNumTotal = totalEmptyAdn + totalEmptyAnr; // Get name string - String strName = mContactData.getDisplayName(); + String strName = contactData.getDisplayName(); ArrayList arrayNumber = new ArrayList(); ArrayList arrayEmail = new ArrayList(); - for (RawContact rawContact : mContactData.getRawContacts()) { + for (RawContact rawContact : contactData.getRawContacts()) { for (DataItem dataItem : rawContact.getDataItems()) { if (dataItem.getMimeType() == null) { continue; -- cgit v1.2.3