1. Introduction to favorites on the desktop
The launcher desktop has four elements in the middle, which are the window widgets of a clock. The following lines are respectively a camera, an Amazon bookmarks, and a folder (the folder contains settings and clock ).
In the code, they are all favorites: appwidget, application, shortcut, and folder.
2. view the database
Favorites is stored in the database.
Export the database file data/COM. Android. launcher/databases/launcher. DB
Structure of the favorites table
Data in the table, corresponding to Figure 1
Intent close-up
3. Introduction to the favorites table in the database
· _ Id · name displayed by title · intent · Container: container_desktop =-100, default value; container_hotseat =-101, resident at the bottom of the screen, the bottom line on the mobile phone, no on the tablet, so Brower in Figure 3 does not exist in Figure 1; clock in Figure 3, container of settings is 6, indicating that they belong to folder. · The Screen to which the screen belongs. · Position on the X axis of cellx. · Celly position on the Y axis. · Spanx width. The default value is 1. · Spany height. The default value is 1. · Itemtype: item_type_application = 0; item_type_shortcut = 1; items = 2; items = 3; item_type_appwidget = 4; · appwidgetid · isshortcut · icontype · iconpackage · iconresource · icon · URI · displaymode
For details, see launcher2 \ SRC \ com \ Android \ launcher2 \ launchersettings. java.
4. Add the default favorites to the desktop
The default favorite on launcher is defined in launcher2 \ res \ XML \ default_workspace.xml. (Launcher2 \ res \ xml-sw600dp \ default_workspace.xml, launcher2 \ res \ xml-sw720dp \ default_workspace.xml)
<?xml version="1.0" encoding="utf-8"?><favorites xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" > <appwidget launcher:className="com.android.alarmclock.AnalogAppWidgetProvider" launcher:packageName="com.android.deskclock" launcher:screen="4" launcher:spanX="2" launcher:spanY="2" launcher:x="2" launcher:y="0" /> <favorite launcher:className="com.android.camera.CameraLauncher" launcher:packageName="com.android.gallery3d" launcher:screen="4" launcher:x="1" launcher:y="3" /> <shortcut launcher:icon="@drawable/ic_home_voice_search_holo" launcher:screen="4" launcher:title="@string/application_name" launcher:uri="https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000626391" launcher:x="2" launcher:y="3" /> <folder launcher:icon="@drawable/ic_launcher_home" launcher:screen="4" launcher:title="@string/folder_name_format" launcher:x="3" launcher:y="3" > <favorite launcher:className="com.android.settings.Settings" launcher:packageName="com.android.settings" /> <favorite launcher:className="com.android.deskclock.DeskClock" launcher:packageName="com.android.deskclock" /> </folder> <!-- Hotseat (We use the screen as the position of the item in the hotseat) --> <favorite launcher:className="com.android.browser.BrowserActivity" launcher:container="-101" launcher:packageName="com.android.browser" launcher:screen="4" launcher:x="4" launcher:y="0" /></favorites>
5. Tool attachment and introduction
I wrote a program to help generate default_workspace.xml. Unfortunately, the program does not support shortcut and folder.
Download
Before adding an application or widget to the launcher, you need to find the package name, class name, and position, and then manually add it to the code. Now, you only need to drag the Add button on the desktop and run the program to generate a layout file for the current desktop application and widget and save it in/mnt/sdcard/default_workspace.xml. Replace packages \ apps \ launcher2 \ res \ xml-sw720dp \ default_workspace.xml.
Press the back key and there are other