Android laucher Summary

Source: Internet
Author: User

I have been working on a launcher project on Android for about a month. With the launch of R3, it basically enters the maintenance phase. Most of the time, I made modifications in the source code launcher provided by Android, therefore, we have a basic concept of its overall structure. Now we will begin to summarize some details and follow international practices and the principle from whole to local, I will first describe launcher as a whole:

From the perspective of manifestl, the first step is to set some permissions (plus: <uses-SDK Android: minsdkversion = "7"/>) and then an application (plus: Android: debuggable = "true"), followed by two activities. One is our main program launcher, the other one is also clear from the name. wallpaperchooser (used to find and list all images with specific tag names and use their return values as background images. ---> I modified them here, use the startactivityforresult function to let them return resid, which serves as all
Progaram page background ).

The next two schedulers are used to install and uninstall the shortcut. From the perspective of the name, we don't know what the shortcut is. After my attempt, the shortcut cut here mainly does not refer to the application icons, but is like opening a browser and creating a webpage shortcut to the desktop. The creation and uninstallation of shortcuts are controlled by the two schedulers. The functions can be seen from their corresponding java files. It should be noted that when the Configurator is configured in manifest, the aggreger is already running when the program starts.

The last part is a provider. Anyone familiar with Android knows that this is used to manage databases. In launcher, there is a special class launcherprovider used to provide specific database operations, sqliteopenhelper is used to create and obtain databases. I will add this part later. Now, the manifest section has been summarized. Next, let's look at main. XML (launcher. XML ):

Its hierarchy is very readable: draglayer ---> workspace ---> celllayout

---> Deletezone

---> Menubar

---> Programpage

Draglayer blocks the movement and painting of all the dragtargets on the screen (mainly for widgets, shortcut, and folder on the screen, because I do not have shortcut and folder here, so only for widgets ).

Workspace is a key class, mainly dealing with operations related to screen switching (such as moving wallpaper and calculating mobile distance) add widgets for the current screen, process long-pressed current screen (setlongclick is related to launcher and so on), and search for Blank grids on the current screen to add widgets, it contains five celllayout stands for five screens respectively. celllayout defines how many spaces are there for the horizontal and vertical axes, and saves all the blank grids with arrays, when one resource is used, the corresponding occupied array is set to true. Of course, there are many other operations in celllayout. Here we will explain them first.

Menubar is very simple. Due to project requirements, I added menubar below the screen to add the shortcut cut. Therefore, the operation of menubar is to process the addition, movement, storage, and deletion of icons.

Programpage is used to display all programs and save them by category. It also allows you to move, add, switch, save, and delete programs. This viewgroup actually includes two parts: programcatagorylist and allprogrampage.

A catagory corresponds to a allproagrampage.

Here, I have analyzed manifest and Main. XML (launcher. XML), and the subsequent content begins to elaborate on the details.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.