Fix SmartForwardingActivity crash at screen rotation
When SmartForwardingActivity attempts to set the Toolbar to ActionBar
in #onCreate, an llegalStateException is thrown. This is because
SmartForwardingFragment sets the default action bar by window decor to
ActionBar first by updating the title in #onCreatePreferences.
This occurs in cases where SmartForwardingFragment is created in the
process of being SmartForwardingActivity created, such as when rotating
SmartForwardingActivity.
Use getActivity()#setTitle instead of getActionBar()#setTitle.
Test: manual
Bug: 314232525
Change-Id: I041d62605ba666ecce041086854e675d9b19ac45
diff --git a/src/com/android/settings/sim/smartForwarding/SmartForwardingFragment.java b/src/com/android/settings/sim/smartForwarding/SmartForwardingFragment.java
index a95eb38..f847147 100644
--- a/src/com/android/settings/sim/smartForwarding/SmartForwardingFragment.java
+++ b/src/com/android/settings/sim/smartForwarding/SmartForwardingFragment.java
@@ -48,8 +48,7 @@
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.smart_forwarding_switch, rootKey);
- String title = getResources().getString(R.string.smart_forwarding_title);
- getActivity().getActionBar().setTitle(title);
+ getActivity().setTitle(R.string.smart_forwarding_title);
TwoStatePreference smartForwardingSwitch = findPreference(KEY_SMART_FORWARDING_SWITCH);
if (turnOffSwitch) {