Brief Analysis on the creation process of snapshot cut in launcher

Source: Internet
Author: User

This document usesContactsOfDirect dialFor example, to parse the process of creating a snapshot cut in launcher

Direct dialInAndroidmanifest. XML (contacts)The statement is as follows:

         <  Activity-alias  Android: Name  = "Alias. dialshortcut"  Android: targetactivity  = ". Activities. contactselectionactivity" Android: Label  = "@ String/shortcutdialcontact"  Android: icon  = "@ Mipmap/ic_launcher_shortcut_directdial"  Android: Enabled  = "@ * Android: bool/config_voice_capable"  >              <  Intent-Filter  >                  <  Action  Android: Name  = "Android. Intent. Action. create_shortcut"  />                  <  Category  Android: Name  = "Android. Intent. Category. Default"   />                  <  Category  Android: Name  = "Android. Intent. Category. car_mode"   />              </  Intent-Filter  >          </  Activity-alias > 

In this wayLauncherOfWidgetsPage to findDirect dial (Android. Intent. Action. create_shortcut).

We willDirect dialAfter dragging to the desktopSend. Activities. contactselectionactivity. Select a contact.Direct dial.

ClickShortcutThe page will jump to the call interface for the selected contact.

Below is what I playedLogImportant steps are marked red.

-----------InLauncher widgetPage SelectionDirect dial(Shortcut) And dragLauncherMain Interface-----------

Dragcontroller --> ontouchevent () --> motionevent. action_up, try to do drop ()

Dragcontroller --> drop ()

Workspace --> ondrop ()

Workspace --> ondropexternal ()

Launcher --> processshortcutfromddrop () --> componentname: COM. Android. Contacts/alias. dialshortcut

Launcher --> resetaddinfo ()

Launcher --> processshortcut ()

Launcher --> startactivityforresultsafely () --> requestcode: 1

Draglayer --> clearanimatedview ()

Contactselectionactivity --> oncreate () -- start

Contactselectionactivity --> oncreate () --> mactioncode:-1

Contactselectionactivity --> configurelistfragment () --> mactioncode: 120

Contactselectionactivity --> oncreate () -- end

Launcher --> updaterunning ()

--------------------------For the newly createdDirect dialShortcut: select a contact--------------------------

Phonenumberpickerfragment --> onitemclick () --> position: 0, ID: 1

Phonenumberpickerfragment --> pickphonenumber () --> URI: Content: // com. Android. Contacts/data/1

Shortcutintentbuilder --> createphonenumbershortcutintent () --> URI: Content: // com. Android. Contacts/data/1, shortcutaction: Android. Intent. Action. Call

Shortcutintentbuilder --> phonenumberloadingasynctask --> loaddata () --> mdisplayname:Gaojx, Mphotoid: 0, mphonenumber: 155 2487, mphonetype: 2, mphonelabel: NULL

Shortcutintentbuilder --> phonenumberloadingasynctask --> onpostexecute ()

Shortcutintentbuilder --> createphonenumbershortcutintent ()

Phonenumberpickerfragment --> onshortcutintentcreated ()

Contactselectionactivity --> phonenumberpickeractionlistener --> onshortcutintentcreated ()

Contactselectionactivity --> returnpickerresult ()

Launcher --> onactivityresult () --> requestcode: 1, resultcode:-1

Launcher --> onactivityresult () --> resultcode = result_ OK & mpendingaddinfo. container! = Iteminfo. no_id

Launcher --> completeadd () --> args. requestcode: 1

Launcher --> completeaddshortcut () --> container:-100, screen: 2, cellx: 1, celly: 2

Launcher --> createshortcut () --> Start

Bubletextview --> applyfromshortcutinfo () --> info. Title:Gaojx

Launcher --> createshortcut () --> end

Workspace --> createuserfolderifnecessary ()

Workspace --> addtoexistingfolderifnecessary ()

Launchermodel --> additemtodatabase ()

Workspace --> addinscreen ()

Launcher --> resetaddinfo ()

Draglayer --> clearanimatedview ()

Launcher --> exitspringloadeddragmodedelayed () --> successfuldrop: True

Launcher --> updaterunning ()

Launcher --> showworkspace ()

Launcher --> showworkspace () --> mstate! = State. Workspace

Launcher --> updaterunning ()

----------------------------ClickLauncherTheDirect dial --------------------------------

Launcher --> onclick ()

Launcher --> onclick () --> tag instanceof shortcutinfo

Launcher --> startactivitysafely ()

Launcher --> startactivity () --> action => Android. Intent. Action. Call, Data => Tel: 155% 202487

Outgoingcallbroadcaster --> oncreate ()

Outgoingcallbroadcaster --> processintent () --> intent = intent {act = android. intent. action. call dat = Tel: xxxxxxxxxxxxx flg = 0x14800000 CMP = com. android. phone /. outgoingcallbroadcaster bnds = [120,387] [240,543]}

Launcher --> updaterunning ()

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

Through the aboveLogWe can see that the process of cut is:

1: declaration specified targetactivity attribute: launcher Create shortcut cut used. That is, launcher startactivityforresultsafely will start the set targetactivity , let's select this shortcut corresponding contact.

2. CallLauncherOfOnactivityresult () to truly completeShortcut.

3. Click Shortcut Will be called Launcher Of Onclick The function processes click events and finally passes Launcher Of Startactivitysafely Function call Startactivity Function ( Parameters Intent From Onactivityresult () Get To ) Complete this Shortcut .

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.