diff options
-rw-r--r-- | AndroidManifest.xml | 3 | ||||
-rw-r--r-- | src/com/android/settings/Settings.java | 27 |
2 files changed, 29 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 22f7300cb..7e0fa15a3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -49,7 +49,8 @@ <activity android:name="Settings" android:label="@string/settings_label" android:taskAffinity="com.android.settings" - android:theme="@android:style/Theme.Holo"> + android:theme="@android:style/Theme.Holo" + android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.settings.SETTINGS" /> diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 738acc3e2..de1a63c02 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -17,6 +17,7 @@ package com.android.settings; import android.app.Fragment; +import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; @@ -31,6 +32,32 @@ public class Settings extends PreferenceActivity implements // TODO: Update Call Settings based on airplane mode state. /** + * Checks if the component name in the intent is different from the Settings class and + * returns the class name to load as a fragment. + */ + private String getStartingFragmentClass(Intent intent) { + final String intentClass = intent.getComponent().getClassName(); + if (intentClass.equals(getClass().getName())) return null; + + return intentClass; + } + + /** + * Override initial header when an activity-alias is causing Settings to be launched + * for a specific fragment encoded in the android:name parameter. + */ + @Override + public Header onGetInitialHeader() { + String fragmentClass = getStartingFragmentClass(super.getIntent()); + if (fragmentClass != null) { + Header header = new Header(); + header.fragment = fragmentClass; + return header; + } + return super.onGetInitialHeader(); + } + + /** * Populate the activity with the top-level headers. */ @Override |