From 03cb4bf2207089e7ae0357ca8ffdadbda968e0f1 Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Wed, 28 Jan 2015 15:53:35 -0800 Subject: [PATCH] Settings: Fix inflate exception on search. Dynamically replace nested fragment. When PrivacyGuard is opened, the parent fragment would inflate the layout which contained a nested fragment. This is bad behavior. Since we couldn't keep track of the fragments lifecycle, the fragment we instantiated during inflation would cause an inflate exception if and when we toggled the search view within the current context. Mitigate the crash by programmatically replacing the fragment after instantiating it once. AndroidRuntime E FATAL EXCEPTION: main E Process: com.android.settings, PID: 12372 E android.view.InflateException: Binary XML file line #21: Error inflating class fragment E at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) E at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) E at android.view.LayoutInflater.inflate(LayoutInflater.java:504) ... E Caused by: java.lang.IllegalArgumentException: Binary XML file line #21: Duplicate id 0x7f1001a2, tag nul l, or parent id 0xffffffff with another fragment for com.android.settings.privacyguard.PrivacyGuardPrefs E at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2120) E at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177) E at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733) E ... 25 more Change-Id: I6820ad7d35814f150eedf91140e21c0b8e23322b --- res/layout/privacy_guard_manager.xml | 3 +-- .../privacyguard/PrivacyGuardManager.java | 22 +++++++++---------- .../privacyguard/PrivacyGuardPrefs.java | 10 ++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/res/layout/privacy_guard_manager.xml b/res/layout/privacy_guard_manager.xml index 8ba35832934..57b7b246ced 100644 --- a/res/layout/privacy_guard_manager.xml +++ b/res/layout/privacy_guard_manager.xml @@ -18,9 +18,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> -