Fix launching of specific settings.
This commit is contained in:
@@ -49,7 +49,8 @@
|
|||||||
|
|
||||||
<activity android:name="Settings" android:label="@string/settings_label"
|
<activity android:name="Settings" android:label="@string/settings_label"
|
||||||
android:taskAffinity="com.android.settings"
|
android:taskAffinity="com.android.settings"
|
||||||
android:theme="@android:style/Theme.Holo">
|
android:theme="@android:style/Theme.Holo"
|
||||||
|
android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="android.settings.SETTINGS" />
|
<action android:name="android.settings.SETTINGS" />
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
|
||||||
@@ -30,6 +31,32 @@ public class Settings extends PreferenceActivity implements
|
|||||||
|
|
||||||
// TODO: Update Call Settings based on airplane mode state.
|
// 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.
|
* Populate the activity with the top-level headers.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user