Catch ActivityNotFoundExceptions
Catch ActivityNotFoundException when attempting to insert or edit a contact.
Bug:12837767
Change-Id: I46688c1f6c59515ff48ddadeaa92e4a74e803eb8
(cherry picked from commit 1d815e67ea1304d693b9e09e7e53e76dc61883e1)
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0d25bb25..7cd8227 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -330,6 +330,11 @@
was found that could perform the selected action. [CHAR LIMIT=NONE] -->
<string name="quickcontact_missing_app">No app was found to handle this action.</string>
+ <!-- Shown as a toast when the user attempts an action (add contact, edit
+ contact, etc) and no application was found that could perform that
+ action. [CHAR LIMIT=NONE] -->
+ <string name="missing_app">No app was found to handle this action.</string>
+
<!-- The menu item to share the currently viewed contact [CHAR LIMIT=30] -->
<string name="menu_share">Share</string>
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index 1eb610a..bf65bdd 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -20,6 +20,7 @@
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.app.Fragment;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -39,6 +40,7 @@
import android.widget.SearchView;
import android.widget.SearchView.OnCloseListener;
import android.widget.SearchView.OnQueryTextListener;
+import android.widget.Toast;
import com.android.contacts.ContactsActivity;
import com.android.contacts.R;
@@ -538,7 +540,13 @@
if (extras != null) {
intent.putExtras(extras);
}
- startActivity(intent);
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "startActivity() failed: " + e);
+ Toast.makeText(ContactSelectionActivity.this, R.string.missing_app,
+ Toast.LENGTH_SHORT).show();
+ }
finish();
}