Proficient in Android
Basic Information
Original Title: Pro Android 4
Author: (India) Satya komatineni (US) Dave MacLean [Translator's profile]
Translator: Zeng Shao Ning Yang Yue
Series name: Turing programming Series
Press: People's post and telecommunications Press
ISBN: 9787115297150
Mounting time:
Published on: February 1, January 2013
Start: 16
Page number: 1
Version: 1-1
Category: Computer> Software and programming> mobile development> android
More about and proficient in Android
Introduction
Books
Computer books
"Proficient in Android" has been comprehensively improved on the basis of the previous version. It not only has the corresponding structure adjustment, but also keeps pace with the times in terms of content. It has increased the knowledge of Android internal components, describes threads, processes, long-running services, broadcast receivers, alarm manager, device configuration changes, and asynchronous tasks. All the new content such as fragment, fragment dialog box, actionbar, and drag-and-drop are even more appealing. In addition, this book makes significant improvements to the relevant sections of services and sensors.
Proficient in Android covers all the knowledge required by Android Developers. It not only lays a solid foundation for Android Developers, but also improves the skills of Android Developers.
Directory
Proficient in Android
Chapter 1 Introduction to the android computing platform 1
1.1 new platform for new PC 1
1.2 Android History 2
1.3 Dalvik VM analysis 4
1.4 understand Android software stack 5
1.5 Use Android SDK to develop end user applications 6
1.5.1 Android simulator 6
1.5.2 Android UI 7
1.5.3 basic Android components 7
1.5.4 advanced UI concepts 8
1.5.5 Android service component 10
1.5.6 Android media and telephone components 10
1.5.7 Android Java package 11
1.6 use Android Source Code 14
1.6.1 online browsing Android Source Code 14
1.6.2 use git to download Android source code 15
1.7 example Project 16 of this book
1.8 summary 16
Chapter 17 set the development environment 17
2.1 set the Environment 17
2.1.1 download JDK 6 18
2.1.2 download eclipse 3.6 19
2.1.3 download Android SDK 19
2.1.4 command line window 20
2.1.5 install ADT 21
2.2 understand basic components 23
2.2.1 view 23
2.2.2 activity 23
2.2.3 fragment 24
2.2.4 intent 24
2.2.5 contentprovider 24
2.2.6 service 24
2.2.7 androidmanifest. xml 24
2.2.8 AVD 25
2.3 Hello world! 25
2.4 AVD 29th
2.5 run on real devices 30
2.6 Structure Analysis of Android applications 31
2.7 Understand application lifecycle 33
2.8 simple debugging 35
2.9 references 37
2.10 Summary 37
2.11 interview question 37
Chapter 5 Use Android Resources 39
3.1 resource 39
3.1.1 string resource 39
3.1.2 layout resource 41
3.1.3 resource reference syntax 43
3.1.4 define the resource ID for future use 44
3.1.5 compiled and uncompiled Android resources 45
3.2 key Android resources 46
3.3 Use any XML resource file 54
3.4 use original resources 55
3.5 assets used 56
3.6 understand the Resource Directory structure 56
3.7 Resource and configuration change 56
3.8 Reference URL 59
3.9 conclusion 60
3.10 Interview Questions 60
Chapter 2 contentprovider 62
4.1 explore Android's built-in contentprovider 63
4.1.1 using databases on simulators and available devices 63
4.1.2 quick introduction to SQLite 66
4.2 contentprovider architecture 66
4.2.1 structure of Android content URI 68
4.2.2 structure of Android MIME type 68
4.2.3 use URI to read data 70
4.2.4 Use cursor 71
4.2.5 use where clause 72
4.2.6 insert record 74
4.2.7 add files to contentprovider 75
4.2.8 update and delete 76
4.3 implement contentprovider 76
4.3.1 planned database 76
4.3.2 extended contentprovider 78
4.3.3 fulfill MIME type contract 83
4.3.4 query method 83
4.3.5 insert method 83
4.3.6 update method 84
4.3.7 Delete method 84
4.3.8 use urimatcher to parse URI 84
4.3.9 use projection ing 85
4.3.10 register the provider 86
4.4 exercise book providers 86
4.4.1 add books 86
4.4.2 delete a book 87
4.4.3 number of books retrieved: 87
4.4.4 show book list 87
4.5 Resource 88
4.6 Summary 89
4.7 interview question 89
Chapter 2 intent 90
5.1 Android intent basic knowledge 90
5.2 available intent 91 in Android
5.3 intent composition 93
5.3.1 intent and data URI 93
5.3.2 general operations 94
5.3.3 use extra information 95
5.3.4 using components to directly call activity 96
5.3.5 intent category 97
5.3.6 resolve intent to Rule 99 of the component
5.4 exercise using action_pick 101
5.5 exercise using get_content 103
5.6 suspended intent 104
5.7 Resource 105
5.8 Conclusion 106
5.9 interview questions 106
Chapter 5 build user interfaces and use controls 6th
6.1 UI development in Android 107
6.1.1 fully utilize code to build UI 108
6.1.2 build UI 110 using XML
6.1.3 use XML and code to build UI 111
6.2 common controls in Android 113
6.2.1 text control 113
6.2.2 button control 116
6.2.3 imageview control 123
6.2.4 control of Date and Time 124
6.2.5 mapview control 127
6.3 adapter 127
6.3.1 simplecursoradapter 128
6.3.2 understand arrayadapter 129
6.4 Use the adapter and adapterview 131 in combination
6.4.1 basic list control: listview 131
6.4.2 gridview control 138
6.4.3 spinner control 140
6.4.4 gallery control 141
6.4.5 create a custom adapter 142
6.4.6 Other Android controls 146
6.5 style and theme 147
6.5.1 use style 147
6.5.2 subject 149
6.6 layout manager 150
6.6.1 linearlayout layout manager 150
6.6.2 tablelayout la Manager 153
6.6.3 relativelayout la Manager 156
6.6.4 framelayout la Manager 157
6.6.5 gridlayout layout Manager 159
6.6.6 configure a custom Layout for various devices 160
6.7 references 161
6.8 conclusion 161
6.9 interview questions 161
Chapter 4 Use menu 7th
7.1 Android menu 163
7.1.1 create menu 164
7.1.2 use menu 165
7.1.3 response menu item 166
7.2 use other menu types 168
7.2.1 expanded menu 168
7.2.2 use the icon menu 169
7.2.3 use sub menu 169
7.2.4 use context menu 170
7.2.5 use alternate menu 173
7.2.6 dynamic menu 175
7.3 load menu 175 through XML file
7.3.1 XML menu resource file structure 176
7.3.2 fill in XML menu resource file 177
7.3.3 respond to XML-based menu item 177
7.3.4 pop-up menu 4.0 in version 178
7.3.5 introduction to other XML menu tags 179
7.4 Resource 181
7.5 conclusion 181
7.6 interview questions 181
Chapter 2 multi-purpose fragment 8th
8.1 what is fragment 183
8.1.1 when to use fragment 184
8.1.2 shard structure 185
8.1.3 fragment lifecycle 186
8.1.4 demo fragment application that shows the lifecycle 189
8.2 fragmenttransactions and fragment rollback stack 194
8.3 fragmentmanager 196
8.3.1 precautions for referencing fragments 197
8.3.2 save part status 198
8.3.3 listfragments and [fragment] 198
8.3.4 call the independent activity 200 as needed
8.3.5 fragment persistence 201
8.4 communication between fragments: 202
8.5 use objectanimator to customize the animation 203
8.6 references 205
8.7 conclusion 205
8.8 interview questions 206
Chapter 2 dialog box 9th
9.1 use Android dialog box 207
9.2 dialog box fragment 207
9.2.1 basic knowledge of dialogfragment 208
9.2.2 build dialog box fragmentation 208
9.2.3 dialogfragment sample application 212
9.3 use toast 220
9.4 fragments in the dialog box of the old Android version 221
9.5 references 221
9.6 conclusion 222
9.7 interview questions 222
Chapter 2 actionbar 10th
10.1 actionbar analysis 223
10.2 tab navigation operation bar activity 225
10.2.1 basic activity 225
10.2.2 allocate a Unified Behavior for actionbar 227
10.2.3 implement tab listener 229
10.2.4 implement tab operation bar activity 230
10.2.5 scrollable debugging Text View layout 232
10.2.6 interaction between the operation bar and menu 233
10.2.7 Android description file 235
10.2.8 test tab operation bar activity 235
10.3 List navigation operation bar activity 236
10.3.1 create a spinneradapter 236
10.3.2 create a list listener 237
10.3.3 setting List Operation column 237
10.3.4 modify the baseactionbar-activity 238
10.3.5 change androidmanifest. xml 238
10.3.6 test List Operation bar activity 239
10.4 standard navigation operation bar activity 240
10.4.1 set standard navigation operation bar activity 240
10.4.2 modify baseactionbar-activity 241
10.4.3 change androidmanifest. xml 242
10.4.4 Test Standard Operation bar activity 242
10.5 toolbar and search view 243
10.5.1 define the search view part as a menu item 244
10.5.2 configure search result activity 244
10.5.3 Custom Search by searching XML files 245
10.5.4 define search result activity 245 in configuration list file
10.5.5 determine the search Target of the search view Part 245
10.6 operation bar and fragment 246
10.7 references 246
10.8 Conclusion 247
10.9 interview questions 247
Chapter 2 advanced debugging and analysis 11th
11.1 enable advanced debugging 249
11.2 debug perspective 249
11.3 ddms perspective 250
11.4 hierarchy view perspective 252
11.5 traceview 253
11.6 ADB command 254
11.7 simulator console 255
11.8 strictmode 255
11.8.1 strictmode policy 255
11.8.2 disable strictmode 256
11.8.3 use strictmode 257 in earlier Android versions
11.8.4 strictmode example 258
11.9 references 259
11.10 conclusion 259
11.11 interview questions 259
Chapter 4 Response to configuration changes 12th
12.1 configuration change process 261
12.1.1 activity destruction/creation process 262
12.1.2 destruction/creation process of fragments 263
12.1.3 use fragmentmanager to save fragment status 264
12.1.4 use the setretain-instance 264 part
12.2 method of configuration change for discarding 264
12.3 references 265
12.4 conclusion 265
12.5 interview questions 265
Chapter 2 preferences and storage status 13th
13.1 exploration preference framework 266
13.1.1 list preference 266
13.1.2 checkbox preference 273
13.1.3 edittextpreference 275
13.1.4 ringtonepreference and multiselectlistpreference 276
13.2 organization preferences 276
13.2.1 use preferencecategory 276
13.2.2 create dependent sub-preferences 279
13.2.3 preferences with titles 279
13.3 procedural operation preferences 281
13.3.1 use preference to save status 281
13.3.2 use dialogpreference 282
13.4 references 283
13.5 conclusion 283
13.6 interview questions 283
Chapter 4 exploring security and permissions 14th
14.1 understand the android Security Model 284
14.1.1 Security Concept overview 284
14.1.2 deploy Signature Application 285
14.2 run the security check 290
14.2.1 process boundary security 290
14.2.2 declaration and permission 290
14.2.3 understanding and using custom permissions 292
14.2.4 understand and use URI permissions 297
14.3 references 298
14.4 conclusion 298
14.5 interview questions 299
Chapter 4 building and using services 15th
15.1 use HTTP service 300
15.1.1 use httpclient for http get request 300
15.1.2 use httpclient for http post requests (multi-part POST request example) 302
15.1.3 soap, JSON, and XML analytics 304
15.1.4 Exception Handling 305
15.1.5 multithreading 307
15.1.6 funny timeout 309
15.1.7 use httpurlconnection 310
15.1.8 use androidhttpclient 310
15.1.9 use background thread (asynctask) 311
15.1.10 use downloadmanager to get the file 316
15.2 use Android 321
15.2.1 Android service 322
15.2.2 local service 323
15.2.3 aidl service 329
15.2.4 define service interface 329 In aidl
15.2.5 aidl interface 331
15.2.6 call service 333 from client applications
15.2.7 deliver complex types to services 336
15.3 references 345
15.4 conclusion 345
15.5 interview questions 346
Chapter 4 Package 16th
16.1 packages and processes 347
16.1.1 specification details 347
16.1.2 convert package name to process name 347
16.1.3 List Installed packages 348
16.1.4 Delete package 348 through the package Browser
16.2 package signature process review 349
16.2.1 understanding of digital signatures: Scenario 1 349
16.2.2 Understanding digital signature: Scenario 2 350
16.2.3 a Digital Signature mode 350
16.2.4 digital signature execution method 350
16.2.5 signature process impact 350
16.3 share data between packages 351
16.3.1 nature of the shared user ID 351
16.3.2 code mode for data sharing 352
16.4 database project 353
16.4.1 concept of library project 353
16.4.2 nature of database project 353
16.4.3 create database project 355
16.4.4 create an android project 358 using the library
16.4.5 precautions for using database projects 365
16.5 references 365
16.6 conclusion 366
16.7 interview questions 366
Chapter 4 Handling Procedures 17th
17.1 Android components and threads 368
17.1.1 the activity runs 369 on the main thread
17.1.2 the broadcast receiver runs 369 on the main thread
17.1.3 the service runs 369 on the main thread
17.1.4 contentprovider runs 370 on the main thread
17.1.5 single main thread impact 370
17.1.6 thread pool, contentprovider, and external service component 370
17.1.7 thread utility: Found thread 370
17.2 handler 371
17.2.1 impact of holding the main thread 372
17.2.2 use a handler to delay the work on the main thread by 373
17.2.3 example of the source code of the processing program for delayed work 373
17.2.4 construct an appropriate message object 375
17.2.5 send the message object to queue 375
17.2.6 response handlemessage callback 376
17.3 use a working thread 376
17.3.1 call worker thread 376 from menu
17.3.2 communication between the worker thread and the master thread 377
17.4 component and process life 380
17.4.1 lifecycle 380
17.4.2 service lifecycle 381
17.4.3 receiver lifecycle 381
17.4.4 provider lifecycle 382
17.5 references 382
17.6 conclusion 382
17.7 interview questions 383
Chapter 2 asynctask 18th
18.1 implement a simple asynctask 385
18.1.1 implement asynctask generic 385
18.1.2 create asynctask subclass 386
18.1.3 implement the first asynctask 386.
18.1.4 call asynctask 388
18.1.5 onpreexecute () callback method and progress dialog box 388
Method 18.1.6 doinbackground () 389
18.1.7 trigger onprogressupdate () 389
18.1.8 onpostexecute () 390
18.1.9 progress confirmation dialog box 390
18.2 nature of asynctask 392
18.3 device rotation and asynctask 393
18.4 lifecycle method and asynctask 393
18.5 references 393
18.6 conclusion 394
18.7 interview questions 394
Chapter 4 broadcast receiving programs and long-term services 19th
19.1 broadcast receiver 395
19.1.1 send broadcast 395
19.1.2 compile a simple receiving program: Sample Code 396
19.1.3 register the recipient in the description file 396
19.1.4 can accommodate multiple receiving programs 397
19.1.5 out-of-process recipient project 399
19.2 use notification from recipient 399
19.2.1 monitoring notification through notification manager 400
19.2.2 send notification 401
19.2.3 enable activity 404 in the broadcast Receiver
19.3 long-running receiving programs and services 404
19.3.1 broadcast receiver protocol for long-term running 404
19.3.2 intentservice 405
19.3.3 intentservice source code 406
19.4 expand intentservice 407 for the broadcast Receiver
19.4.1 long-running broadcast service abstraction 408
19.4.2 long-running receiving program 409
19.4.3 use lightedgreenroom abstraction to wake up lock 411
19.5 implementation of long-term running services 416
19.5.1 details of Non-adhesive services 417
19.5.2 details of the viscosity service 417
19.5.3 variation of non-viscosity: redeliver intent 418
19.5.4 specify the service flag 418 in onstartcommand
19.5.5 select suitable viscosity 418
19.5.6 wake-up lock 418 from two locations
19.5.7 implementation of long-term running services 419
19.5.8 testing of long-term running services 420
19.5.9 responsibilities of developers 420
19.5.10 responsibilities of the Framework 421
19.6 instructions on Project download 421
19.7 references 422
19.8 conclusion 422
19.9 interview questions 422
Chapter 4 alarm manager 20th
20.1 basic knowledge of the alarm MANAGER: Set a simple alarm 424
4.1.1.1 obtain the access permission of the alarm manager 424
20171.2 set the alarm time to 424
4.1.1.3 create an alarm receiving program 425
4.1.1.4 create pendingintent 426 suitable for the alarm
20171.5 set the alarm to 427
4.1.1.6 test project 427
20.2 explore other alarm manager scenarios 428
20172.1 set the recurrence alarm 428
Cancel alarm 429
430
4.1.2.4 intent's primary responsibilities when setting an alarm 432
20172.5 persistence 434 of the alarm clock
20.3 alarm manager fact 434
20.4 references 434
20.5 Conclusion 435
20.6 interview questions 435
Chapter 2 2D animation secrets 21st
21.1 frame-by-frame animation 436
21.1.1 frame-by-frame animation 436
21.1.2 creation activity 438
21.1.3 add an animation to activity 439
21.2 layout animation 441
21.2.1 basic compensation animation type 442
21.2.2 planned layout animation testing tool 442
21.2.3 create an activity and listview 443
21.2.4 create listview as animation 445
21.2.5 use the interpolation tool 447
21.3 view animation 449
21.3.1 view animation 449
21.3.2 add animation 451
21.3.3 use camera to achieve a depth effect of 454 for 2D images
21.3.4 exploration of the animationlistener class 455
21.3.5 instructions on transformation matrices 456
21.4 property Animation: new animation API 457
21.4.1 animation 458
21.4.2 plan a property animation Test Bench 459
21.4.3 use an object animation generator to create a basic view animation 461
21.4.4 use animatorset to implement sequential animation 462
21.4.5 use animatorsetbuilder to set the animation relationship 463
21.4.6 use XML to load the animation generator 463
21.4.7 propertyvaluesholder 464
21.4.8 view property animation 466
21.4.9 type calculator 466
21.4.10 key frame 468
21.4.11 Layout Change 469
21.5 references 470
21.6 conclusion 470
21.7 interview questions 471
Chapter 4 map and location-based services 22nd
22.1 map package 472
22.1.1 get map-API key 473 from Google
22.1.2 mapview and mapactivity 474
22.1.3 Add a 479 mark using an overlay chart
22.2 location package 484
22.2.1 use Android for Geographic Encoding 484
22.2.2 use background threads for Geographic Encoding 487
22.2.3 locationmanager service 489
22.2.4 use mylocationoverlay to display location 495
22.2.5 use close reminder 498
22.3 references 502
22.4 conclusion 502
22.5 interview questions 503
Chapter 4 telephone API 23rd
23.1 use SMS 504
23.1.1 send SMS message 504
23.1.2 monitor incoming SMS messages 507
23.1.3 use the SMS folder 509
23.1.4 send email 511
23.2 use Phone Manager 511
23.3 sip 514
23.3.1 experience sipdemo 514
23.3.2 android.net. Sip package 515
23.4 references 516
23.5 conclusion 517
23.6 interview questions 517
Chapter 4 media framework 24th
24.1 use media API 518
24.2 play media 522
24.2.1 play audio content 522
24.2.2 play video content 532
24.3 recording media 534
24.3.1 use mediarecorder to record audio 535
24.3.2 use audiorecord to record audio 538
24.3.3 video recording 542
24.3.4 mediastore 551
24.3.5 use intnet to record audio 551
24.3.6 add media content to media storage 554
24.3.7 trigger mediascanner 556 for the entire SD card
24.4 references 557
24.5 conclusion 557
24.6 interview questions 558
Chapter 2 home screen parts 25th
25.1 architecture of home screen components 559
25.1.1 what is the home screen part 559
25.1.2 user experience of home screen parts 560
25.1.3 part lifecycle 563
25.2 sample parts application 567
25.2.1 define part provider 568
25.2.2 define part size 569
25.2.3 file related to Part layout 570
25.2.4 implement Part provider 571
25.2.5 implement Part Model 573
25.2.6 implement part configuration activity 579
25.3 part preview tool 582
25.4 limitations and expansion of parts 583
25.5 container-based parts 583
25.6 resource 583
25.7 conclusion 584
25.8 interview questions 584
Chapter 4 List parts 26th
26.1 remote view overview 586
26.2 use list 587 in remote view
26.2.1 prepare remote layout 588
26.2.2 load remote layout 590
26.2.3 create remoteviewsservice 591
26.2.4 create remoteviewsfactory 592
26.2.5 create an onclick event 595
26.2.6 respond to onclick event 597
26.3 working example: test the home screen list part 598
26.3.1 create a test part provider 599
26.3.2 create remote view factory 602
26.3.3 code 604 for the remote view service
26.3.4 part Master Layout file 604
26.3.5 part providers metadata 604
26.3.6 androidmanifest. xml 605
26.4 test list part 605
26.5 references 607
26.6 conclusion 608
26.7 interview questions 608
Chapter 2 touch screen 27th
27.1 motionevent 609
27.1.1 motionevent object 609
27.1.2 reclaim motionevent 619
27.1.3 use velocitytracker 619
27.2 multi-point touch 621
27.3 touch map 627
27.4 gesture 629
27.4.1 kneading gestures 629
27.4.2 gesturedetector and ongesturelistener 629
27.4.3 custom gesture 632
27.4.4 gestures Builder application 632
27.5 references 638
27.6 conclusion 638
27.7 interview questions 638
Chapter 2 drag-and-drop operations 28th
28.1 Drag and Drop Operations 640
28.2 3.0 and later basic drag-and-drop operations 644
28.3 drag and drop operation example application 645
28.3.1 file list 646
28.3.2 layout of the drag-and-drop application in the example 646
28.3.3 respond to dropzone ondrag event 648
28.3.4 create a Drag Source view 650
28.4 test example drag-and-drop application 653
28.5 references 654
28.6 Conclusion 654
28.7 interview questions 654
Chapter 4 sensor 29th
29.1 what is sensor 655
29.1.1 sensor 656
29.1.2 Sensor Information 656
29.2 get sensor events 658
29.3 interpretation of sensor data 661
29.3.1 light sensor 661
29.3.2 proximity sensor 661
29.3.3 Temperature Sensor 662
29.3.4 pressure sensor 662
29.3.5 gyroscope sensor 662
29.3.6 accelerator 663
29.3.7 Magnetic Field Sensor 667
29.3.8 combined use of accelerometer and Magnetic Field Sensor 668
29.3.9 orientation sensor 668
29.3.10 magnetic angle and geomagnetic-field 673
29.3.11 gravity sensor 673
29.3.12 linear acceleration sensor 674
29.3.13 rotating vector sensor 674
29.3.14 Near-Field Communication sensor 674
29.4 references 683
29.5 conclusion 683
29.6 interview questions 684
Chapter 4 contact API 30th
30.1 account 685
30.1.1 account screen overview 686
30.1.2 correlation between accounts and contacts 688
30.1.3 enumeration account 689
30.2 Contact application 689
30.2.1 personal account profile 691
30.2.2 show contact 692
30.2.3 show contact details 692
30.2.4 edit contact details 693
30.2.5 set the contact's photo 694
30.2.6 export contact 694
30.2.7 various contact data types 696
30.3 contact 696
30.3.1 contact SQLite database 697
30.3.2 Original Contact 697
30.3.3 data table 699
30.3.4 aggregation contact 700
30.3.5 view_contact 701
30.3.6 contact_entities_view 702
30.4 contact API 703
30.4.1 view account 703
30.4.2 browse aggregate contact 705
30.4.3 browse Original Contact 712
30.4.4 view raw contact data 715
30.4.5 add contact and its details 718
30.5 control aggregation 720
30.6 synchronization impact 720
30.7 personal account 721
30.7.1 read the original contact 722 of the account
30.7.2 read account contact data 722
30.7.3 add data to personal account 723
30.8 references 725
30.9 conclusion 725
30.10 interview questions 726
Chapter 4 deploy the application Android Market 31st
31.1 became publisher 727
31.1.1 comply with Rule 728
31.1.2 developer console 729
31.2 prepare the sales application 731
31.2.1 test for different devices 732
31.2.2 supports different screen sizes of 732
31.2.3 prepare to upload androidmanifest. xml 732
31.2.4 localized application 733
31.2.5 prepare an application icon 734
31.2.6 considerations for paid applications 734
31.2.7 guide the user to market 735
31.2.8 Android Authorization Service 735
31.2.9 using proguard to optimize and combat piracy 736
31.2.10 Upload File. APK 737
31.3 upload an application 738
31.3.1 diagram 738
31.3.2 list details 739
31.3.3 release option 739
31.3.4 contact information 740
31.3.5 provisions to be observed 740
31.4 Android Market user experience 741
31.5 more release channels 742
31.6 references 742
31.7 conclusion 743
31.8 interview questions 743
Source of this book: China Interactive publishing network