[LG Optimus Black] repulse:
In this tutorial we will cover how to add an item in the settings menu for integration when cooking your own rom, or for personal use. Using windows XP, but should apply to any windows version, Linux users: you most likely are smart enough to use this guide with whatever flavor of linux you're using, so i wont cover linux specific guidelines.

The original reason i began doing this was because i hate clutter in my app drawer, and i like accessing settings for things from the.... you guessed it: Settings menu.

For this tutorial we will use the Spare Parts app, but this applies to almost all applications that you would desire adding.

Materials :

PSPad or Notepad++ (i'll use PSPad in this tutorial, it's just my preference)

APKMultiTool (or any other, like elesbb's GUI APK Tool v1.2.4.5, etc...)

SpareParts APK (or what you want !)

Settings APK from the rom you wish to modify

Archive manager (7z or Winrar, i use Winrar)

A general understanding of using APKMultiTool or APKManager is a great start, i'll try to make this guide friendly to those who arent familiar.

Process :

01) Install APKMultiTool

02) Place both APK files in APKMultiTool's place-apk-here-for-modding folder

03) Start APKMultiTool by double clicking script.bat in the main APKMultiTool folder

04) Select the settings app by typing 25 then enter, then the number next to the settings app then enter

05) Decompile both APKS by selecting option number 9 after selecting the APK from the menu from before

06) Get Back to the APKMultiTool main folder, then enter projects folder, then Settings.apk folder

07) Navigate to res/xml from this folder and open the settings.xml file with pspad (right click and select PSPad or open from pspad directly) to add a new action and icon

08) We'll add it right after the display settings entry, find it and copy the entire selection, then after IconPreferenceScreen> hit enter to make a new line.

09) Paste the entire action, this is what we will edit, you can type it all out word for word, but this is easier, and there is less room for a mistake

10) after pasting, we'll change the values for the new settings action, string name (title), and drawable name (icon) see below pictures

11) change all the references from display to sp or spareparts, or anything you want to call it, just make sure it's consistent as in the next steps we will use the titles and strings you created. the @drawable will be the name of the icon you create, the @string will be the title used to display the menu item. you will need to change the target package to spare part's internal app name (this can be found in the SpareParts project folder inside AndroidManifest.xml)

and the target class (the action within the target package to open or perform). to obtain the target class, the easiest way i've found is installing the app you want to add and using adw and finding a blank area on your homescreen(s), long press, then select custom shortcut>pick your activity>activities>browse down until you find the SpareParts app, and expand with the arrow on the left SpareParts only has one action, but other apps will have several. the first on the list is usually it's opening class it's in the ( )'s in this example it's .SpareParts. the target class is the internal app name.class so here we will add com.android.spare_parts.SpareParts

14) open strings.xml

15) navigate to the bottom of the strings xml and copy the final string and as before at the end press enter and paste to modify a new string. the first part is the string name that you made above, the second is the actually title that will appear in the settings menu (Spare Parts in ths example)

16) save the file and close

17) create a graphic icon (32 pixels by 32 pixels or 32x32) for the selection from the settings menu, we will call it ic_settings_sp.png

18) place this icon in the res/drawable-mdpi folder

19) open the public.xml in the res/values folder where you found the strings.xml file

EDIT : Seems that you don't need to do this, it may cause some troubles when recompiling. So, just jump from step 18 to 24 Thanks RomWiz

20) this takes a little work and a little understanding of how hex numbers work. hex numbers go from 0 to 9 then a-f, this gives sixteen values, so hex numbers conform to this order - 0123456789abcdef the reason this is important is that you need to find the last hex number in the drawable range. the public.xml file is usually not in order so it takes some work and some time to find the number you need to assign a new "id" to the icon, and string we are adding. if you are using a fresh Settings.apk basically you'll take the highest number you've found and add 1 to it using the above hex order until you find a number that doesnt exist. in this example the we find it here:

so copy that line, create a new line under it and add the name of the icon you created and add 1 to the number at the end

21) repeat the above process to add the string we created earlier in the strings section of public.xml

22) save the file and close

24) you are now ready to compile the APK, in the APKMultiTool screen select teh settings.apk using option 25 again and then use option 11 to compile the APK

25) if you get errors, run the log, at the end of the log it will usually list the problem you encountered if you did. if it mentions something being out of range you need to chek to make sure your numbers are correct, if it mentions missing resources you havent properly added the strings or icons

26) if all goes well you will be asked if this is a system apk, either option is fine, the second option is if you want to keep old files to avoid errors. answering no is the easiest way. just answering no to both works fine

27) you should now have a newly compiled APK, in the place-apk-here-for-modding folder with the prefix "unsigned"

28) open both the Settings.apk and unsignedSettings.apk file with winrar or winzip

29) transfer find the icon in the unsignedSettings.apk /res/drawable-mdpi folder and transfer it accordingly to the Settings.apk /res/drawable folder, do the same with the /res/xml/settings.xml and the /resources.arsc file.

30) your new settings apk is now ready to be pushed to /system/app on your device.

31) Optional - if not already installed, place SpareParts.apk into the /system/app folder to make it a system app

32) Optional - if you want to remove SpareParts from the app drawer you'll need to decompile the spare parts apk using the steps above and edit one line from the AndroidManifest.xml file, just delete the entire launcher line it looks like this:

33) Optional - Recompile the SpareParts.xml file and sign it if you wish (SpareParts can be signed, DO NOT perform this step on the Settings.apk file, it will not work due to mismatched signatures in the uid)

Don't forget permissions...

That should be it.