FORUMS
Remove All Ads from XDA

[Tutorial] How to add any App/Option in Settings.apk

2,891 posts
Thanks Meter: 7,850
 
By Saqib Nazm, Retired Forum Moderator / Recognized Themer on 27th June 2013, 06:14 PM
Post Reply Email Thread
This Guide will help you to add any application/options to Settings.apk. Well earlier My friend @sandy7 published a guide on how to add various options in Settings. So this extended guide will provide you the necessary knowledge on how to get resources about any app which needed to be added in Settings to include it as an option.

Requirements:
  • Any Tool that can Decompile & Recompile with it's requirements
  • Notepad++


1. How to add options/apps in main/general settings :

To add an app in Settings we need some resources of the app. This resources can be found by decompiling the app which we want to add & look for those in AndroidManifest.xml
Now, to add an app we need this resources to be added:

*android:targetPackage - the unique & original package name of the app
*android:action - the On click event of an app & it finds the activity of the app
*android:targetClass - the class which is called on calling Onclick action which opens the app when it is clicked
*android:title - the entry of the app in header & also in strings.xml
*android:icon - the icon which will be displayed for the app entry

Notes: android:targetClass, android:targetPackage & android:action can be found in AndroidManifest of the app. For some apps android:targetClass is not given directly. So it should be searched to find. I will tell you how to do that. android:title & android:icon can be written as per user.

As I explained a bit about the resources I will now move onto the main guide. I will take an app from playstore named "Rom Toolbox" as example & describe the ongoing process

i. 1st we need to decompile the Rom toolbox app & find the resources in AndroidManifest.xml



as we can see from the picture that I marked the android:targetPackage & android:targetClass. The target package is easy to find. Sometimes target class is also given directly. If it's not given directly like this app we will find it by searching for it in the lines which starts with <activity. Now if there's more than one activity search for the activity that matches with the target package to some extent. & one more thing I should make you clear about. In some apps you will find android:targetClass will just be a one word phrase. Like if we take Serajr's SystemUI Preference as example you will see that android:targetClass is ".SystemUIPreferencesActivity". In those cases we need to add the whole android:targetPackage before targetClass. For Serajr's SystemUI preference the android:targetPackage="com.serajr.systemui.prefere nces". So the android:targetClass=
"com.serajr.systemui.preferences.SystemUIPreferencesActivity".
So here for Rom Toolbox app we find

Code:
android:targetPackage="com.jrummy.liberty.toolbox"
android:targetClass="com.jrummy.apps.rom.toolbox.RomToolboxActivity"
android:action="android.intent.action.MAIN"
android:action doesn't always needed to be found, you can always use "android.intent.action.MAIN" as the on click event

ii. Now decompile Settings.xml & go to res\xml & open settings_header.xml with notepad++. Now chose a place where you want to make the entry. If we want to add the app under advanced settings then we need to create a header 1st. We also need to create an android:title & android:icon entry for the app. So this will be the entry in settings_header

Code:
    </header>
    <header android:title="@string/header_category_advanced" />
    <header android:icon="@drawable/ic_settings_rom" android:title="@string/rom_toolbox">
        <intent android:targetPackage="com.jrummy.liberty.toolbox" android:action="android.intent.action.MAIN" android:targetClass="com.jrummy.apps.rom.toolbox.RomToolboxActivity" />
The 1st header is for the advanced settings header. We need to make an entry of the same name in strings.xml.
The 2nd header is for the app & icon. We need to write the exact entry as title in strings.xml like I wrote "rom_toolbox". You can write anything as title just make sure it matches the app itself so that you can find it easily. So the settings_header will look like this



Now save it

iii. Now go to res\values & open strings.xml. We need to create two strings here. One for the advanced settings & another for the app. We already chose the string name for header as "header_category_advanced" & "rom_toolbox" for the Rom Toolbox app. So the entries in strings.xml will be

Code:
    <string name="header_category_advanced">ADVANCED SETTINGS</string>
    <string name="rom_toolbox">ROM Toolbox</string>
You can write anything where I wrote "ADVANCED SETTINGS" & "ROM Toolbox" It depends on you what you would like to see in settings as header.

So the strings.xml should be like this



Now save it.

iv. Now we need to place a png for the app in drawable folder with the name "ic_settings_rom" as it is given in the header of android:icon. Depending on your settings you either should have drawable hdpi or drawable mdpi folder. On my case I have drawable hdpi folder. 1st we need to look at the resolutions of the pngs which starts with ic_settings name. Well generally for drawable hdpi it is 48x48 & for drawable mdpi it is 32x32. So we need to resize the png in any of this resolutions depending on our drawable folder. You can take the png from the original app & resize it. In my case I resized it in 48x48 & placed it in drawable-hdpi folder.

v. Now you are ready to recompile again. Then try your newly modified settings. I will post a screenshot of mine





2. How to add options/apps in sub settings for example in display settings :

Here I will take On-screen-buttons app for an example in the ongoing process. We will add it in display_settings. Now, we need an extra resource called android:key when we want to add any app in sub settings. android:key is the keystore when the app is extracted using any app tool when created by the developer. As we cannot find the original android:key of the app, we will enter a value as android:key & give it's reference in the ids.xml

i. 1st decompile the On screen button app & search for resources in AndroidManifest.xml.



So we find android:targetPackage="cn.kyle.gn.NavBar" & as only one line here starts with <activity it is really easy to find android:targetClass="cn.kyle.gn.NavBar.GnNavBarAct ivity". android:action="com.android.intent.MAIN" even if it is not written in the manifest.
Now we need to make android:title which can be anything,we just need to refer it into strings.xml, android:key can be anything, we need to refer it in ids.xml & another entry is optional here which is android:summary which is the sub-header of the app. I give you my example what I have written as values of those resources

Code:
android:title="navienable_title"
android:key="on_screen"
android:summary="on_screen_summary"


Now as we fixed every resource & their values we will put the entry in res\xml in display_settings.xml. The entry will look like this


Code:
    <PreferenceScreen android:title="@string/navienable_title" android:key="on_screen" android:summary="@string/on_screen_summary">
        <intent android:targetPackage="cn.kyle.gn.NavBar" android:action="android.intent.action.MAIN" android:targetClass="cn.kyle.gn.NavBar.GnNavBarActivity" />
    </PreferenceScreen>


The display_settings will look like this



Now save it

ii. Now go to res/values & open strings.xml. We need to make two entries here. One for the android:title="@string/navienable_title" & another for the android:summary="@string/on_screen_summary". Now we make the entries

Code:
    <string name="navienable_title">On-Screen-Buttons</string>
    <string name="on_screen_summary">Enable/Disable On-Screen-Buttons</string>
as I said before you can write anything inside >......</string> it depends on you what text you would like to be seen

The screenshot from strings.xml



Now save it.

iii. Now go to res\values\ids.xml & open it. We need to make an entry for the entry we made in display_settings as android:key. So the entry will be with the same value

Code:
    <item type="id" name="on_screen">false</item>
So the ids.xml should be like this



Save it & recompile your edited Settings.apk. Here is a screenshot of the Settings I edited






2. How to add headers in Settings/about to display Developer Name & Rom Name :

i. Decompile Settings.apk & go to res\xml & open device_info_settings.xml. Now choose a place where you want to show your Rom Name & Developer name. The entries you need here are similar with the one's that already exist in the xml. So you can copy one line of entry & press enter then paste it & you can edit it to make the new entries. We need android:title & android:summary which will be shown in strings.xml. We need android:key which you can keep same as android:title to eliminate difficulties, but we don't need an entry in ids.xml this time as it is not an app for which we are making the entry for. Last of all we need a style entry which will be the same as others. So I will write my Rom name & developer name under Kernel_version entry here. The entries will be


Code:
    <Preference android:title="@string/rom_header" android:key="rom_header" android:summary="@string/rom_name" style="?android:preferenceInformationStyle" />
    <Preference android:title="@string/author_header" android:key="author_header" android:summary="@string/author_name" style="?android:preferenceInformationStyle" />
The device_info_settings.xml will look like this



Now save it.

ii. Now go to res\values\strings.xml to make the entries here. We need two entries for the Rom Name, one is for "@string/rom_header" & another for "@string/rom_name". Same we need for Devloper name, one entry for "@string/author_header" & another for "@string/author_name". So the entries will be


Code:
    <string name="rom_header">Rom Name</string>
    <string name="rom_name">X Rom</string>
    <string name="author_header">Developed By</string>
    <string name="author_name">Saqib Nazm</string>
I give my Rom name as "X Rom" for example. You can type anything as you like on rom_name & author_name

The strings.xml should look like this



Now save it & recompile. Enjoy your freshly made new Settings.apk. Here is a screenshot about how it looks



.................................................. .................................................. .....................................

At the end I want to say, I will try to explain it more by adding more examples so that you can add anything. Kindly give me credits for my work If it helps you in anyway possible. Like I am gonna give credits to those respective people for whom I could share this guide to you.

Credits:
  • Neroyoung - for always helping me & clearing my ideas
  • jerrytan93 - for helping me alot whenever I need him
  • gagan.u20 - for always saving me if I get stuck somewhere
  • singh_dd93 - for giving me a clear idea on some resources
  • sandy7 - who doesn't know his thread from where everyone can learn
The Following 114 Users Say Thank You to Saqib Nazm For This Useful Post: [ View ] Gift Saqib Nazm Ad-Free
 
 
28th June 2013, 10:10 AM |#2  
jerrytan93's Avatar
Senior Member
Thanks Meter: 6,299
 
Donate to Me
More
Nice one.. now everyone can start to develop their own ROM..
The Following 4 Users Say Thank You to jerrytan93 For This Useful Post: [ View ] Gift jerrytan93 Ad-Free
28th June 2013, 05:30 PM |#3  
Saqib Nazm's Avatar
OP Retired Forum Moderator / Recognized Themer
Flag Virginia, USA
Thanks Meter: 7,850
 
Donate to Me
More
Quote:
Originally Posted by jerrytan93

Nice one.. now everyone can start to develop their own ROM..

hehe thanks man & your help is highly appreciated
The Following 4 Users Say Thank You to Saqib Nazm For This Useful Post: [ View ] Gift Saqib Nazm Ad-Free
28th June 2013, 06:07 PM |#4  
sandy7's Avatar
Inactive Recognized Developer
Flag bangalore
Thanks Meter: 6,932
 
Donate to Me
More
@saqib nazm

i think u should add this also

after adding an app to settings u dont want that app to show up on launcher ..

so u can hide it by editing Androidmanifest.xml

by delete the red marked line


Code:
 <activity android:label="@string/app_name" android:name=".GalleryActivity" android:taskAffinity="android.task.pictures" android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
The Following 13 Users Say Thank You to sandy7 For This Useful Post: [ View ] Gift sandy7 Ad-Free
28th June 2013, 06:15 PM |#5  
Saqib Nazm's Avatar
OP Retired Forum Moderator / Recognized Themer
Flag Virginia, USA
Thanks Meter: 7,850
 
Donate to Me
More
Quote:
Originally Posted by sandy7

@saqib nazm

i think u should add this also

after adding an app to settings u dont want that app to show up on launcher ..

so u can hide it by editing Androidmanifest.xml

by delete the red marked line


Code:
 <activity android:label="@string/app_name" android:name=".GalleryActivity" android:taskAffinity="android.task.pictures" android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />



yeah sure I wanted to,but then thought it doesn't work for every app.like it gives fc on 1st case then if applied later it works Now as you wrote it in the 1st page I think I don't need to add it OP anymore if you change the title of your post
The Following 2 Users Say Thank You to Saqib Nazm For This Useful Post: [ View ] Gift Saqib Nazm Ad-Free
28th June 2013, 06:35 PM |#6  
jader13254's Avatar
Senior Member
Flag Hamburg
Thanks Meter: 18,025
 
Donate to Me
More
Quote:
Originally Posted by saqib nazm

yeah sure I wanted to,but then thought it doesn't work for every app.like it gives fc on 1st case then if applied later it works Now as you wrote it in the 1st page I think I don't need to add it OP anymore if you change the title of your post

It works for every app.
Just set it for the main activity from
Code:
 <activity android:label="@string/app_name" android:name=".GalleryActivity" android:taskAffinity="android.task.pictures" android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
to
Code:
 <activity android:label="@string/app_name" android:name=".GalleryActivity" android:taskAffinity="android.task.pictures" android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
cheers,

jan+
The Following 9 Users Say Thank You to jader13254 For This Useful Post: [ View ] Gift jader13254 Ad-Free
28th June 2013, 07:29 PM |#7  
Saqib Nazm's Avatar
OP Retired Forum Moderator / Recognized Themer
Flag Virginia, USA
Thanks Meter: 7,850
 
Donate to Me
More
Quote:
Originally Posted by jader13254

It works for every app.
Just set it for the main activity from
cheers,
jan+

thanks jader I didn't know that. So it's good to know that now from you
29th June 2013, 01:05 PM |#8  
vishal_android freak's Avatar
Inactive Recognized Developer / Recognized Contributor
Flag Mumbai
Thanks Meter: 5,797
 
Donate to Me
More
awesomeness.. people like you make people like us who are learning easy to understand things.. thanks bro..

Sent from my HTC Explorer A310e using xda app-developers app
29th June 2013, 01:38 PM |#9  
Nice tutor m8 ! Thanx 4 ur aW£s0m€ work !!

Sent from my E15i using xda premium
29th June 2013, 02:24 PM |#10  
Envious_Data's Avatar
Senior Member
Imagination
Thanks Meter: 2,291
 
Donate to Me
More
how would i?
Quote:

saqib nazm

how would i Add a another menu Below the Development menu , because i do want to Add a Credits menu

ps is it posible to add a rom control menu with the sony white balance app, navigation bar, font changer or/and a dpi changer
29th June 2013, 05:30 PM |#11  
Saqib Nazm's Avatar
OP Retired Forum Moderator / Recognized Themer
Flag Virginia, USA
Thanks Meter: 7,850
 
Donate to Me
More
Quote:
Originally Posted by Envious_Data

how would i Add a another menu Below the Development menu , because i do want to Add a Credits menu

ps is it posible to add a rom control menu with the sony white balance app, navigation bar, font changer or/and a dpi changer

so you want to add a credit option in settings?& when you click on it what do you want it to do? sony white balance is not yet ported perfectly to our devices & also there is no font changer in our phone (or is it an app?) how to add dpi changer is given in other thread by sandy7.
The Following User Says Thank You to Saqib Nazm For This Useful Post: [ View ] Gift Saqib Nazm Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes