1.在资源文件:packages/apps/Settings/res/xml/settings_headers.xml 中添加对应的应用列表
[Code]
<?xml version="1.0" encoding="utf-8"?>
<preference-headers
xmlns:android="http://schemas.android.com/apk/res/android">
:
<!-- Language -->
<header
android:id="@+id/language_settings"
android:fragment="com.android.settings.inputmethod.InputMethodAndLanguageSettings"
android:icon="@drawable/ic_settings_language"
android:title="@string/language_settings" />
<!-- MyApp -->
<header
android:key="my_app"
android:id="@+id/myapp_settings"
android:icon="@drawable/ic_settings_myapp"
android:title="@string/myapp_settings_title" >
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.test.my.app"
android:targetClass="com.test.my.app.MyAppActivity"/>
</header>
:
</preference-headers>
其中涉及到的icon ,title(string)添加对应的res/drawable-hdpi , res/values/Strings.xml
2.在Code为添加的列表注册事件:packages/apps/Settings/src/com/android/settings/Settings.java
[Code]
:
private static final String MYAPP_PACKAGE = "com.test.my.app";
private static final String MYAPP_CLASS_NAME = "com.test.my.app.MyAppActivity";
:
private void updateHeaderList(List<Header> target) {
int i = 0;
while (i < target.size()) {
Header header = target.get(i);
// Ids are integers, so downcasting
int id = (int) header.id;
if (id == R.id.dock_settings) {
:
} else if (id == R.id.myapp_settings){
// If we don't have an MyApp APK, remove that option
Intent myappIntent = new Intent();
myappIntent.setClassName(MYAPP_PACKAGE, MYAPP_CLASS_NAME);
myappIntent.setAction(Intent.ACTION_MAIN);
PackageManager pm = getPackageManager();
List<ResolveInfo> myappApks = pm.queryIntentActivities(myappIntent, 0);
if(myappApks == null || myappApks.isEmpty()) {
target.remove(header);
}
}
:
}
3.修改完之后: make Settings
source build/envsetup.sh
lunch [选择 XXX ]
mmm package/apps/Settings
adb push out/target/product/XXX/system/app/Settings.apk system/app
...Test....Debug...T....D....T...
[End]
-Hope can help you-