diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/nfc/AndroidBeam.java | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java index 2d8d6fe..eb3ff9b 100644 --- a/src/com/android/settings/nfc/AndroidBeam.java +++ b/src/com/android/settings/nfc/AndroidBeam.java @@ -16,6 +16,7 @@ package com.android.settings.nfc; +import android.app.ActionBar; import android.app.Fragment; import android.nfc.NfcAdapter; import android.os.Bundle; @@ -39,12 +40,27 @@ public class AndroidBeam extends Fragment public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - SettingsActivity activity = (SettingsActivity) getActivity(); + final ActionBar actionBar = getActivity().getActionBar(); - mOldActivityTitle = activity.getActionBar().getTitle(); - activity.getActionBar().setTitle(R.string.android_beam_settings_title); + mOldActivityTitle = actionBar.getTitle(); + actionBar.setTitle(R.string.android_beam_settings_title); mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + mView = inflater.inflate(R.layout.android_beam, container, false); + + return mView; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + SettingsActivity activity = (SettingsActivity) getActivity(); mSwitchBar = activity.getSwitchBar(); mSwitch = mSwitchBar.getSwitch(); @@ -52,22 +68,24 @@ public class AndroidBeam extends Fragment } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - mView = inflater.inflate(R.layout.android_beam, container, false); + public void onResume() { + super.onResume(); mSwitchBar.addOnSwitchChangeListener(this); mSwitchBar.show(); - mSwitch.setChecked(mNfcAdapter.isNdefPushEnabled()); + } - return mView; + @Override + public void onPause() { + super.onPause(); + + mSwitchBar.removeOnSwitchChangeListener(this); + mSwitchBar.hide(); } @Override public void onDestroyView() { super.onDestroyView(); - mSwitchBar.removeOnSwitchChangeListener(this); - mSwitchBar.hide(); if (mOldActivityTitle != null) { getActivity().getActionBar().setTitle(mOldActivityTitle); } |