Fix launching of specific settings.

This commit is contained in:
Amith Yamasani
2010-09-27 12:03:59 -07:00
parent 6021a81381
commit 379d9b05cf
2 changed files with 29 additions and 1 deletions

View File

@@ -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" />

View File

@@ -17,6 +17,7 @@
package com.android.settings;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
@@ -30,6 +31,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.
*/