Failed to find provider in android TV Preferences fragment - android

Getting Failed to find provider com.google.android.katniss.search.searchapi.VoiceInteractionProvider for user 0; expected to find a valid ContentProvider for this authority for tv Preference Fragment
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.omniwyse.tvprefdemo, PID: 2025
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.omniwyse.tvprefdemo/com.omniwyse.tvprefdemo.SettingActivity}: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.v17.preference.BaseLeanbackPreferenceFragment.onCreateRecyclerView(BaseLeanbackPreferenceFragment.java:42)
at android.support.v14.preference.PreferenceFragment.onCreateView(PreferenceFragment.java:270)
at android.support.v17.preference.LeanbackPreferenceFragment.onCreateView(LeanbackPreferenceFragment.java:54)
at android.app.Fragment.performCreateView(Fragment.java:2522)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2426)
at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2205)
at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2161)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2062)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3051)
at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2998)
at android.app.Fragment.performActivityCreated(Fragment.java:2537)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1318)
at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2426)
at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2205)
at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2161)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2062)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3051)
at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2998)
at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:182)
at android.app.Activity.performCreate(Activity.java:7143)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
public class SettingsFragment extends LeanbackSettingsFragment {
#Override
public void onPreferenceStartInitialScreen() {
startPreferenceFragment(new PrefsFragment());
}
#Override
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
final Fragment f =
Fragment.instantiate(getActivity(), pref.getFragment(), pref.getExtras());
f.setTargetFragment(caller, 0);
if (f instanceof PreferenceFragment || f instanceof PreferenceDialogFragment) {
// startPreferenceFragment(f);
} else {
// startImmersiveFragment(f);
}
return true;
}
#Override
public boolean onPreferenceStartScreen(PreferenceFragment caller, PreferenceScreen pref) {
final Fragment f = new PrefsFragment();
final Bundle args = new Bundle(1);
args.putString(PreferenceFragment.ARG_PREFERENCE_ROOT, pref.getKey());
f.setArguments(args);
startPreferenceFragment(f);
return true;
}
}
#SuppressLint("ValidFragment")
public class PrefsFragment extends LeanbackPreferenceFragment {
#Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource
setPreferencesFromResource(R.xml.preferences, rootKey);
}
}

I solve this issue by changing theme preference Theme.Leanback
On your manifest file :
<activity android:name=".ui.setting.YourSettingPrefActivity"
android:exported="true"
android:theme="#style/Theme.Pref.LeanbackPreferences"/>
And here on styles.xml
<style name="Theme.Pref.LeanbackPreferences" parent="Theme.Leanback">
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Leanback</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:colorPrimary">#color/fastlane_background</item>
</style>

Related

How to use navigation entry (NavHostFragment) and databinding in activity?

I want to use databinding at the entrance to the navigation.
When I use fragment(android:name="NavHostFragment") in the activity, the program can run normally;
but when I use fragment in the activity (android:name="NavHostFragment") + databinding, the program will not run.
Please help me, I hope to use databinding at the entrance of the navigation, please tell me how to use it, thank you! !
Exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.appnavigationtodo/com.example.appnavigationtodo.MainActivity}: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3092)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3235)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6990)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #21: Duplicate id 0x7f080050, tag null, or parent id 0xffffffff with another fragment for androidx.navigation.fragment.NavHostFragment
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3752)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:120)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:405)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:387)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
at com.example.appnavigationtodo.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Activity.performCreate(Activity.java:7317)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3235)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6990)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
MainActivity.java:
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding activityMainBinding;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activityMainBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
}
}
activity_main.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ToolbarTheme" />
<fragment
android:id="#+id/fragmentMain"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:defaultNavHost="true"
app:navGraph="#navigation/nav_main" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="#menu/menu_bottom_navigation_view" />
</LinearLayout>
</layout>
You're calling setContentView twice, once with setContentView and a second time with DataBindingUtil.setContentView(). Instead, just use DataBindingUtil.setContentView(), which calls setContentView() itself internally:
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding activityMainBinding;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityMainBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
}
}

Error inflating class (not found)RingtonePreference

My app is crashing every time I try to open settings activity. Without RingtonePreference in the XML file it's all work fine. Stacktrace:
07-25 05:30:39.244 3406-3406/com.ovchinnikovm.android.vktop E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ovchinnikovm.android.vktop, PID: 3406
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ovchinnikovm.android.vktop/com.ovchinnikovm.android.vktop.settings.SettingsActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class (not found)RingtonePreference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class (not found)RingtonePreference
at android.support.v7.preference.PreferenceInflater.createItemFromTag(PreferenceInflater.java:297)
at android.support.v7.preference.PreferenceInflater.rInflate(PreferenceInflater.java:354)
at android.support.v7.preference.PreferenceInflater.rInflate(PreferenceInflater.java:356)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:162)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:112)
at android.support.v7.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:137)
at android.support.v7.preference.PreferenceFragmentCompat.setPreferencesFromResource(PreferenceFragmentCompat.java:448)
at com.ovchinnikovm.android.vktop.settings.SettingsFragment.onCreatePreferences(SettingsFragment.java:21)
at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:224)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2331)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1386)
at android.support.v4.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1188)
at android.support.v4.app.FragmentTransition.calculateFragments(FragmentTransition.java:1071)
at android.support.v4.app.FragmentTransition.startTransitions(FragmentTransition.java:115)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2380)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2338)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2245)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3248)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3200)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:195)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:597)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1245)
at android.app.Activity.performStart(Activity.java:6581)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2523)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.preference.RingtonePreference" on path: DexPathList[[zip file "/data/app/com.ovchinnikovm.android.vktop-2/base.apk", zip file "/data/app/com.ovchinnikovm.android.vktop-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.ovchinnikovm.android.vktop-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.ovchinnikovm.android.vktop-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.ovchinnikovm.android.vktop-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.ovchinnikovm.android.vktop-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.ovchin
Xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="#string/notifications_title"
android:key="notification_title">
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="enable_notifications"
android:summary="#string/enable_notification_summary"
android:title="#string/notifications_title" />
<RingtonePreference
android:key="pref_tone"
android:title="#string/pref_tone"
android:showDefault="true"
android:ringtoneType="notification"
android:showSilent="true"/>
</PreferenceCategory>
</PreferenceScreen>
Java class:
public class SettingsActivity extends AppCompatActivity {
public static final String KEY_PREF_NOTIFICATION_SWITCH = "enable_notifications";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
}
Fragment:
public class SettingsFragment extends PreferenceFragmentCompat {
#Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
}
}
Part of gradle where I add support libraries:
implementation "com.android.support:appcompat-v7:27.1.1"
implementation 'com.android.support:support-v13:27.1.1'
implementation "com.android.support.constraint:constraint-layout:1.1.2"
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation 'com.android.support:preference-v7:27.1.1'
Part of the strings.xml file that related to SettingsActivity:
<!-- Settings Screen -->
<string name="settings_label">Settings</string>
<string name="notifications_title">Notifications</string>
<string name="enable_notification_summary">Notifications report the end of the sorting when app is minimized</string>
<string name="pref_tone">Notification ringtone</string>

Android InflateException caused on Menu Selection

I am using a preference fragment, and I get a exception on my XML. It used to work, but I've tweaked something and now it consistently crashes when I press the 3 dots in the top right hand for the menu.
The actual error is:
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.sherman.android.babynme/org.sherman.android.babynme.Activites.SettingsActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
Here is my activity_settings.xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android='http://schemas.android.com/apk/res/android'
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/activity_settings"
android:name="org.sherman.android.babynme.Fragments.SettingsFragment" />
my preferencesXML:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:defaultValue="Name"
android:key="baby_name"
android:title="Baby's Name" />
<EditTextPreference
android:defaultValue="01/01/01"
android:key="baby_dob"
android:title="Baby's Birthday" />
<EditTextPreference
android:numeric="integer"
android:defaultValue="21"
android:key="mum_age"
android:singleLine="true"
android:title="Your age" />
</PreferenceScreen>
My SettingsActivity.kt:
class SettingsActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
val sharedPreferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val babyName:String = sharedPreferences.getString("baby_name", "Baby")
title = babyName+" 'n Me"
val actionBar = this.supportActionBar
if(actionBar != null){
actionBar.setDisplayHomeAsUpEnabled(true)
}
}
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
val id = item?.itemId
if(id == android.R.id.home){
NavUtils.navigateUpFromSameTask(this)
}
return super.onOptionsItemSelected(item)
}
}
And the code for the SettingsFragment:
class SettingsFragment: PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener {
val mContext = context
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_baby)
val sharedPreferences: SharedPreferences = android.preference.PreferenceManager.getDefaultSharedPreferences(activity.applicationContext)
onSharedPreferenceChanged(sharedPreferences, "baby_name")
onSharedPreferenceChanged(sharedPreferences, "baby_dob")
onSharedPreferenceChanged(sharedPreferences, "mum_age")
}
override fun onResume() {
super.onResume()
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
//activity.getSharedPreferences(context.packageName, Context.MODE_PRIVATE).registerOnSharedPreferenceChangeListener(this)
}
override fun onPause() {
super.onPause()
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
//activity.getSharedPreferences(context.packageName,Context.MODE_PRIVATE).unregisterOnSharedPreferenceChangeListener(this)
}
override fun onSharedPreferenceChanged(p0: SharedPreferences?, key: String?) {
Log.d(DEBUG, "Ospc called")
val pref: Preference = findPreference(key)
val etp: EditTextPreference = pref as EditTextPreference
pref.setSummary(etp.text)
}
Here is the full error log:
--------- beginning of crash
02-12 19:44:06.931 4518-4518/org.sherman.android.babynme E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.sherman.android.babynme, PID: 4518
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.sherman.android.babynme/org.sherman.android.babynme.Activites.SettingsActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class fragment
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:255)
at android.support.v7.preference.Preference.getPersistedString(Preference.java:1601)
at android.support.v7.preference.EditTextPreference.onSetInitialValue(EditTextPreference.java:92)
at android.support.v7.preference.Preference.dispatchSetInitialValue(Preference.java:1517)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1245)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1257)
at android.support.v7.preference.PreferenceGroup.addPreference(PreferenceGroup.java:194)
at android.support.v7.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:126)
at android.support.v7.preference.PreferenceInflater.rInflate(PreferenceInflater.java:355)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:162)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:112)
at android.support.v7.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:138)
at android.support.v7.preference.PreferenceFragmentCompat.addPreferencesFromResource(PreferenceFragmentCompat.java:432)
at org.sherman.android.babynme.Fragments.SettingsFragment.onCreatePreferences(SettingsFragment.kt:20)
at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:224)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2339)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1640)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1896)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3673)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:338)
at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
02-12 19:44:06.933 4518-4518/org.sherman.android.babynme E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at org.sherman.android.babynme.Activites.SettingsActivity.onCreate(SettingsActivity.kt:15)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
My Question is what did I change that caused the menu selection to crash now? (Thank You).
The problem is Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
You must have changed the data types somewhere.

Runtime Exception in Preference Fragment

I have a preference fragment with the following files
preference.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:defaultValue="0000"
android:key="#string/pin"
android:summary="Set Pin for Notes"
android:title="Password" />
</PreferenceScreen>
Preference Activity
public class PreferenceActivity extends AppCompatActivity {
#BindView(R.id.toolbar_settings)
Toolbar toolbarSettings;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
setSupportActionBar(toolbarSettings);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
}
and finally
Preference Fragment
public class PreferenceFragment extends PreferenceFragmentCompat {
#Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preference);
}
}
But here when the addPreferencesFromResources is called, I am getting a runtime exception.
Here is the log stack
Exception
02-21 22:23:36.574 8813-8813/in.snotes.snotes E/AndroidRuntime: FATAL EXCEPTION: main
Process: in.snotes.snotes, PID: 8813
java.lang.RuntimeException: Unable to start activity ComponentInfo{in.snotes.snotes/in.snotes.snotes.settings.PreferenceActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class fragment
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:225)
at android.support.v7.preference.Preference.getPersistedString(Preference.java:1601)
at android.support.v7.preference.EditTextPreference.onSetInitialValue(EditTextPreference.java:92)
at android.support.v7.preference.Preference.dispatchSetInitialValue(Preference.java:1517)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1245)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1257)
at android.support.v7.preference.PreferenceGroup.addPreference(PreferenceGroup.java:194)
at android.support.v7.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:126)
at android.support.v7.preference.PreferenceInflater.rInflate(PreferenceInflater.java:355)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:162)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:112)
at android.support.v7.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:138)
at android.support.v7.preference.PreferenceFragmentCompat.addPreferencesFromResource(PreferenceFragmentCompat.java:432)
at in.snotes.snotes.settings.PreferenceFragment.onCreatePreferences(PreferenceFragment.java:12)
at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:224)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2246)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1650)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1906)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3698)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:350)
at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
02-21 22:23:36.575 8813-8813/in.snotes.snotes E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at in.snotes.snotes.settings.PreferenceActivity.onCreate(PreferenceActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
I had a switch preference before the edit text preference and that worked fine. Once i replaced the switch preference with edit text preference, this error is thrown.
How do I fix this?
Can you try the code below?
strings.xml
<string name="pin_default_value">0000</string>
preference.xml
<EditTextPreference
android:defaultValue="#string/pin_default_value"
android:key="#string/pin"
android:summary="Set Pin for Notes"
android:title="Password" />
Android is trying to set default value but it is reading 0000 as an Integer and not as a String Main reason is that android:defaultValue is not directly handled as String. This way, to avoid this int to Stringconversion error, you must explicit use a String value (by using some string from strings.xml.
Note
You may need to clear your app data since that wrong default value may be stored in cached files already.

switching to another tab more than once gives EEROR

i have a tabbed activity.
When i switch from tab1 to tab2 or 3,the app runs smooth.
Again i switch to tab1 and then switch to any other tab,the app crashes.
Tabbed activity java code
public class MainActivity extends AppCompatActivity {
ViewPager vp;
TabLayout tab;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vp= (ViewPager) findViewById(R.id.viewpager);
tab= (TabLayout) findViewById(R.id.tab);
vp.setAdapter(new CustomAdapter(getSupportFragmentManager(),MainActivity.this));
tab.setupWithViewPager(vp);
tab.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
#Override
public void onTabSelected(TabLayout.Tab tab) {
vp.setCurrentItem(tab.getPosition());
}
#Override
public void onTabUnselected(TabLayout.Tab tab) {
}
#Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
private class CustomAdapter extends FragmentPagerAdapter
{
private String fragments[]={"District","NearBy","Search"};
public CustomAdapter(FragmentManager supportFragmentManager, Context applicationContext)
{
super(supportFragmentManager);
}
#Override
public Fragment getItem(int position)
{
switch (position)
{
case 0:
return new MqmDList();
case 1:
return new MqmLList();
case 2:
return new Mqm_MList();
default:
return null;
}
}
#Override
public int getCount() {
return fragments.length;
}
#Override
public CharSequence getPageTitle(int position) {
return fragments[position];
}
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0) {
Intent homeIntent = new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory( Intent.CATEGORY_HOME );
homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
}
return super.onKeyDown(keyCode, event);
}
}
Error
05-06 12:37:38.380 3356-3356/soft.yu.com.maqam E/Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
05-06 12:37:40.451 3356-3560/soft.yu.com.maqam E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.googlecertificates.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/soft.yu.com.maqam-1/base.apk"],nativeLibraryDirectories=[/data/app/soft.yu.com.maqam-1/lib/x86, /system/lib, /vendor/lib]]
05-06 12:37:48.548 3356-3356/soft.yu.com.maqam E/AndroidRuntime: FATAL EXCEPTION: main
Process: soft.yu.com.maqam, PID: 3356
android.view.InflateException: Binary XML file line #5: Binary XML file line #5: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #5: Duplicate id 0x7f0d0081, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2293)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at soft.yu.com.maqam.Mqm_MList.onCreateView(Mqm_MList.java:67)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1430)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:732)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:608)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:570)
at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:551)
at soft.yu.com.maqam.MainActivity$1.onTabSelected(MainActivity.java:29)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1025)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:995)
at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1272)
at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1377)
at android.view.View$PerformClick.run(View.java:22215)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:6066)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:770)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:660)
05-06 12:39:06.671 4725-4725/soft.yu.com.maqam E/Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
05-06 12:39:08.120 4725-4725/soft.yu.com.maqam E/SurfaceTexture: isProtectedSurface: invalid current EGLDisplay
[ 05-06 12:39:08.122 4725: 4826 D/ ]
HostConnection::get() New Host Connection established 0xa9457af0, tid 4826
05-06 12:39:08.736 4725-4828/soft.yu.com.maqam E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.googlecertificates.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/soft.yu.com.maqam-1/base.apk"],nativeLibraryDirectories=[/data/app/soft.yu.com.maqam-1/lib/x86, /system/lib, /vendor/lib]]
05-06 12:39:11.825 4725-4725/soft.yu.com.maqam E/AndroidRuntime: FATAL EXCEPTION: main
Process: soft.yu.com.maqam, PID: 4725
android.view.InflateException: Binary XML file line #5: Binary XML file line #5: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #5: Duplicate id 0x7f0d0081, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2293)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at soft.yu.com.maqam.Mqm_MList.onCreateView(Mqm_MList.java:67)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1430)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:732)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:608)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:570)
at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:551)
at soft.yu.com.maqam.MainActivity$1.onTabSelected(MainActivity.java:29)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1025)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:995)
at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1272)
at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1377)
at android.view.View$PerformClick.run(View.java:22215)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:6066)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:770)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:660)
05-06 12:39:20.267 4948-4948/soft.yu.com.maqam E/Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
05-06 12:39:20.388 4948-4948/soft.yu.com.maqam E/SurfaceTexture: isProtectedSurface: invalid current EGLDisplay
[ 05-06 12:39:20.388 4948: 5066 D/ ]
HostConnection::get() New Host Connection established 0xab02c370, tid 5066
05-06 12:39:22.332 4948-5070/soft.yu.com.maqam E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.googlecertificates.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/soft.yu.com.maqam-1/base.apk"],nativeLibraryDirectories=[/data/app/soft.yu.com.maqam-1/lib/x86, /system/lib, /vendor/lib]]
05-06 12:39:25.434 4948-4948/soft.yu.com.maqam E/AndroidRuntime: FATAL EXCEPTION: main
Process: soft.yu.com.maqam, PID: 4948
android.view.InflateException: Binary XML file line #5: Binary XML file line #5: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #5: Duplicate id 0x7f0d0081, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2293)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at soft.yu.com.maqam.Mqm_MList.onCreateView(Mqm_MList.java:67)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1430)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:732)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:608)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:570)
at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:551)
at soft.yu.com.maqam.MainActivity$1.onTabSelected(MainActivity.java:29)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1025)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:995)
at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1272)
at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1377)
at android.view.View$PerformClick.run(View.java:22215)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:6066)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:770)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:660)
i have a tabbed activity.
When i switch from tab1 to tab2 or 3,the app runs smooth.
Again i switch to tab1 and then switch to any other tab,the app crashes.
i have a tabbed activity.
When i switch from tab1 to tab2 or 3,the app runs smooth.
Again i switch to tab1 and then switch to any other tab,the app crashes.
You have to remove map fragment when changing tab. It worked for me ;)
#Override public void onDestroyView() {
super.onDestroyView();
FragmentManager fm = getActivity().getSupportFragmentManager();
Fragment fragment = (fm.findFragmentById(R.id.mapd));
FragmentTransaction ft = fm.beginTransaction();
ft.remove(fragment);
ft.commit();
}

Categories

Resources