Android Launcher development details

Source: Internet
Author: User

Chapter 2 launch

1.1 Framework launch Launcher Process

 


1.2 Launcher Startup Process
App-Launcher-data loading and UI binding
Directory [hide]
1. Launcher desktop data and Main Menu Data Loading Process
1.1 load Main Menu data
1.1.1 1. Load the call Process
1.2 1.2 load desktop data
1.3 Data Loading During SIM card insertion
1.4 1.4 classic Bug
1.4.1 166085
 
[Edit] 1. launcher desktop data and Main Menu data loading process [edit] 1.1 load Main Menu data PackageManager load the application data structure, AppwidgetsManager load the widget data structure, and load the desktop data structure from the Favorites Database

 
 

[Edit] 1. Load call process LoaderTask a task is to load the desktop, a task is to load the drawer, synchronization (one by one. LauncherModel: waitForIdle () method is used to wait until the desktop is loaded and then load the drawer.
Wait for the completion of loadAndBindWorkspace from the favorite table, that is, the desktop data is loaded from the database to the memory object, and has been displayed to the desktop Workspace,
Then start loadAndBindAllApps to load PackageManager. After obtaining data from the launcher-loader sub-thread, use mHandler. postIdle () mHandler. post () post the task to the DefferedHandler: mQueue of the main thread task queue to update the UI.


/** Runs the specified runnable immediately if called from the main thread, otherwise it is
* Posted on the main thread handler .*/
Private void runOnMainThread (Runnable r ){
If (sWorkerThread. getThreadId () = Process. myTid ()){
// If we are on the worker thread, post onto the main handler
MHandler. post (r );
} Else {
R. run ();
}
}
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is
* Posted on the worker thread handler .*/
Private static void runOnWorkerThread (Runnable r ){
If (sWorkerThread. getThreadId () = Process. myTid ()){
R. run ();
} Else {
// If we are not on the worker thread, then post to the worker handler
SWorker. post (r );
}
}
When you click the main menu button, bind the data obtained by loadallmediabybatch to PagedViewIcon. AppsCustomizePagedView: syncAppsPageItems constructs the ApplicationInfo array and adds each PagedViewIcon to PagedViewCellLayout.


For (int I = startIndex; I <endIndex; ++ I ){
ApplicationInfo info = mApps. get (I );
PagedViewIcon icon = (PagedViewIcon) mLayoutInflater. inflate (
R. layout. apps_customize_application, layout, false );
Icon. applyFromApplicationInfo (info, true, this );
PagedViewCellLayout. addViewToCellLayout (icon,-1, I, new PagedViewCellLayout. LayoutParams (x, y, 1,1 ));
Items. add (info );
Images. add (info. iconBitmap );
}
LoaderTask: run () ---> LoaderTask: loadAndBindAllApps () ---> LoaderTask: loadall1_bybatch () --->
Launcher: bindAllApplications () ---> AppsCustomizePagedView: setApps () ---> AppsCustomizePagedView: invalidateOnDataChange ()

 

 
 

Before clicking the "Main Menu" button, the AppsCustomizePagedView does not have any Child. the execution sequence is as follows: AppsCustomizeTabHost. onMeasure (...) ---> AppsCustomizePagedView. onMeasure (...) ---> AppsCustomizePagedView. onDataReady (...) ---> (AppsCustomizePagedView) PagedView. invalidatePageData ---> AppsCustomizePagedView: syncPages ()

[Edit] 1.2 load desktop data LauncherModel: startLoader ---> LoaderTask: bindWorkspace ---> LoaderTask: bindWorkspaceItems ---> Launcher: bindItems

 
 

[Edit] 1.3 Data Loading Problem During SIM card insertion 1. Launcher will execute onDestory () onCreate () on Launcher Activtiy because of low memory, and will execute again


StartLoader --> loadAndBindWorkSpace ----> loadAndBindAllApps

2. Launcher Registers act = android. intent. action. CONFIGURATION_CHANGED Reload apps on config change. curr_mcc: 460 prevmcc: 0. when identifying the SIM, it also executes

StartLoader --> loadAndBindWorkSpace ----> loadAndBindAllApps
However, in both cases, when startLoader is called, malluploloaded = false and mWorkspaceLoaded = false. Therefore, the following code is actually executed and the data structure ArrayList is not reloaded. <ApplicationInfo>

StartLoader --> BindWorkSpace ----> onlyBindAllApps

--------------------------------------------------------------------------------

Private void loadAndBindAllApps (){
If (DEBUG_LOADERS ){
Log. d (TAG, "loadAndBindAllApps malluploloaded =" + malluploloaded );
}
If (! Malluploloaded ){
LoadAllAppsFromPersistence ();
Loadall1_bybatch ();
Synchronized (LoaderTask. this ){
If (mStopped ){
Return;
}
Malluploloaded = true;
}
} Else {
OnlyBindAllApps ();
}
}

--------------------------------------------------------------------------------
[Edit] 1.4 classic Bug [edit] 166085 Launcher: onCreate () --- new Thread ---> startLoader ---> Read favoriteDB ---> post (bindItem)
|
Launcher: onReume () ---- new Thread ---> getMissedCallCount ---> post (updateCallLogIcon) ------> workspace: updateShortCut ()

When the call starts InCallScreen, Launher: onDestory is executed. When the call ends, Launcher: onCreate is executed. Because startLoader consumes longer time than getMissedCallCount, post (updateCallLogIcon) is executed first, however, at this time, the desktop icon is not bind, resulting in no update of the icons that do not receive incoming calls.

 

 

Chapter 2 Launcher layout and view
2.1 hierarchyviewer study launcher. xml Layout

There are many useful tools in the Android SDK toolkit that can help programmers develop and test Android applications, greatly improving their work efficiency. Hierachy Viewer is one of the visual debugging tools, which can help developers design, debug and adjust interfaces to improve the development efficiency of users.

Chapter 2 Launcher View dragging details

Chapter 2 Launcher appwightet Architecture

Chapter 4 desktop thumbnails

 

 

Related Article

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.