am 0a660fe0: Merge "Fix SocialWidgetConfigureActivity contact-picker double-launch." into jb-dev
* commit '0a660fe03a68777958858738cf4ffdad11a2b7fd':
Fix SocialWidgetConfigureActivity contact-picker double-launch.
diff --git a/src/com/android/contacts/socialwidget/SocialWidgetConfigureActivity.java b/src/com/android/contacts/socialwidget/SocialWidgetConfigureActivity.java
index 98812d9..39307bf 100644
--- a/src/com/android/contacts/socialwidget/SocialWidgetConfigureActivity.java
+++ b/src/com/android/contacts/socialwidget/SocialWidgetConfigureActivity.java
@@ -23,12 +23,19 @@
import android.provider.ContactsContract.Contacts;
public class SocialWidgetConfigureActivity extends Activity {
+ private static final String KEY_LAUNCHED = "already_launched_picker_activity";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the user presses back, we want to cancel
setResult(RESULT_CANCELED);
+ // Don't launch contact-picker if we already launched it (for example, if
+ // we launched it in a previous onCreate() and the device orientation changes
+ // before the picker returns its result, then this activity will be recreated).
+ if (savedInstanceState != null && savedInstanceState.getBoolean(KEY_LAUNCHED)) return;
+
// Forward the Intent to the picker
final Intent pickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
pickerIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -36,6 +43,14 @@
}
@Override
+ protected void onSaveInstanceState(Bundle savedInstanceState) {
+ super.onSaveInstanceState(savedInstanceState);
+
+ // We know for sure that we've launched the contact-picker... see onCreate()
+ savedInstanceState.putBoolean(KEY_LAUNCHED, true);
+ }
+
+ @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// We came back from the Picker. If the user actually selected a contact,
// return it now