The definitive guide to Android development 1st edition
The "Android Development Authority Guide" focuses on the guidance of practical hands-on ability, and while following the rigor of the technology research and development knowledge system, it is equipped with detailed screenshots of development scenarios in links that are prone to errors and are not easy to understand; And present important knowledge points and development skills to readers in the lively form of "learning one more trick", "extended learning", "skill dial", etc. In terms of the explanation of program examples, the examples are mainly inserted in the essence knowledge chapter of Android development, which provides a good guide for readers to combine learning and practice.
Document screenshot:
Part 1 Preparation Chapter 1 First Encounter with the True Face of Lushan - Introduction to Android Development 2 1.1 Basic Concepts of Android 2 1.1.1 Introduction to Android 2 1.1.2 Android version 4 1.1.3 Android System Architecture 5 1.1.4 Android Application Framework 6 1.2 Introduction to JIL Widget 7 1.3 Summary 8 Chapter 2 If you want to do a good job, you must first sharpen your tools - building and using the Android development environment 9 2.1 Installation of development kits and tools 9 2.1.1 What is needed to develop Android programs 9 2.1.2 Installing the JDK and Configuring the Java Development Environment 10 2.1.3 eclipseThe installation with Sinicization 11 2.1.4 Install Android SDK 12 2.1.5 Installing the Eclipse Plugin ADT 13 2.2 Real Experience – Writing the First Android Program (Random Drawing Pie) 15 2.2.1 Creating an Android Project 15 2.2.2 Run Android Programs in Emulators 17 2.2.3 Layout of Interface Controls 19 2.2.4 Writing Code 20 2.2.5 Debugging Procedure 23 2.2.6 Running and Debugging Programs on Mobile Phones 28 2.3 Errors that may occur in the migration project 29 2.4 A development tool that doesn't require a single line of code: AppInventor 31 2.4.1 Introduction to AppInventor 31 2.4.2 Downloading and Installing AppIntentor 31 2.4.3 Designing the Interface by Dragging Controls 33 2.4.4 Assemble Code 34 Like a Puzzle 2.5 Summary 37 Part 2 Basics Chapter 3 A Journey of a Thousand Miles Begins with a Single Step - Android Programming Basics 40 3.1 Android Application Framework 40 3.1.1 Directory Structure of Android Projects 40 3.1.2 AndroidManifest.xml fileThe structure of 42 3.2 Resources in Android Applications 44 3.3 Application Components for Android 44 3.3.1 Activity (Android Forms) 45 3.3.2 Service 45 3.3.3 Broadcast Receiver 45 3.3.4 Content Provider 46 3.4 UI Design of Android Programs 46 3.4.1 Manually Configuring XML Layout Files 46 3.4.2 ADT's Built-in Visual UI Designer 47 3.4.3 Designing UI Layout with DroidDraw 47 3.5 Summary 48 Chapter 4 My UI - Basics of User Interface Development 49 4.1 How to Use Activity 49 4.1.1 Creating Activity 49 4.1.2 Configuring Activity 50 4.1.3 Displaying Other Activities (Intents and Activities) 52 4.2 Activity Lifecycle 55 4.3 Passing Data Between Different Activities 60 4.3.1 Using Intents to Pass Data 60 4.3.2 Passing Data Using Static Variables 62 4.3.3 Using the Clipboard to Transfer Data 63 4.3.4 Passing Data Using Global Objects 65 4.3.5 Return data to the previous Activity 67 4.4 View 68 4.4.1 Introduction to Views 68 4.4.2 Defining Views Using XML Layout Files 69 4.4.3 Control View 70 in Code 4.5 Layout 72 4.5.1 FrameLayout 72 4.5.2 LinearLayout 75 4.5.3 RelativeLayout 79 4.5.4 TableLayout 81 4.5.5 AbsoluteLayout 82 4.5.6 Reusing XML Layout Files 82 4.5.7 Optimizing XML Layout Files 85 4.5.8 Viewingapk fileLayout in 86 4.6 Summary 87 Chapter 5 A Good Start to Learning - Detailed Explanation of Widgets 88 5.1 Parsing Common XML Attributes 88 5.1.1 android:id attribute 88 5.1.2 Width (Android:layout_width) and Height (Android:layout_height) 88 for Controls 5.1.3 android:layout_margin attribute 89 5.1.4 android:padding attribute 89 5.1.5 android: layout_weight attribute 90 5.1.6 android:layout_gravity and android:gravity attributes 90 5.1.7 android:visibility attribute 91 5.1.8 android:background attribute 91 5.1.9 Specifying the Click Event Method (android:onClick Property) 92 5.1.10 Control Focus Properties (android:focusable and android:focusable-InTouchMode) 92 5.2 TextView (Controls for Displaying Text) 93 5.2.1 Displaying Rich Text (URL, Text of Different Sizes, Fonts, Colors) 93 5.2.2 Displaying Emoji Images and Text in TextView 97 5.2.3 Click the link to pop up Activity 100 5.2.4 Adding a Background to Specified Text 103 5.2.5 TextView with Border 106 5.2.6 Set the Line Spacing 110 5.2.7 Adding an ellipsis (...) 111 after unfinished text 5.2.8 Implementing the Marquee Effect with TextView 113 5.2.9 Scrolling Text in TextView Vertically 114 5.3 EditText 115 5.3.1 Input an expression image like QQ 115 5.3.2 Entering a Specific Character 117 in EditText 5.3.3 AutoCompleteText-View (Control for Auto-CompleteText-View) 118 5.4 Button and Checkbox Controls 120 5.4.1 Button (Normal Button Control) 120 5.4.2 Button for Mixing Graphics and Text 122 5.4.3 ImageButton 124 5.4.4 RadioButton 124 5.4.5 ToggleButton 125 5.4.6 CheckBox (Checkbox Control) 126 5.5 ImageView (Control for Displaying Images) 128 5.5.1 Basic Usage of ImageView Control 128 5.5.2 Display of Images of Specified Areas 129 5.5.3 Scaling and Rotating Images 132 5.6 Time and Date Controls 133 5.6.1 DatePicker (Control for Entering Dates) 133 5.6.2 TimePicker (Control for Entering Time) 134 5.6.3 DatePicker, TimePicker, and TextView Synchronously Display Date and Time 134 5.6.4 AnalogClock and DigitalClock (Controls to Display the Clock) 136 5.7 Progress Bar Controls 137 5.7.1 ProgressBar 137 5.7.2 SeekBar 139 5.7.3 Setting the Color and Background of the ProgressBar and SeekBar 140 5.7.4 RatingBar 143 5.8 List Controls 145 5.8.1 ListView (Normal List Control) 145 5.8.2 Adding Checkboxes and Option Buttons to ListView List Items 147 5.8.3 Adding, deleting, and modifying list items 149 5.8.4 Changing the Background Color of List Items 153 5.8.5 ListActivity 154 5.8.6 ExpandableListView 155 5.8.7 Spinner (Drop-down List Control) 157 5.9 Scroll Controls 160 5.9.1 ScrollView (Vertical Scroll Control) 160 5.9.2 HorizontalScrollView 161 5.9.3 Vertical and Horizontal Scrollable Views 162 5.9.4 Gallery 163 5.10 ImageSwitcher 164 5.11 GridView 166 5.12 TabHost (Tag Control) 168 5.13 ViewStub 169 5.14 Summary 171 Chapter 6 Friendly Menus - Menu Introduction and Examples 172 6.1 Basic Usage of Menus 172 6.1.1 Creating an Options Menu 172 6.1.2 Options Menu with Images 173 6.1.3 Associate Activity 173 6.1.4 Click Action of Response Menu 174 6.1.5 Dynamic Add, Modify, and Delete Options Menu 175 6.1.6 Submenu 176 with Checkboxes and Options Buttons 6.1.7 Context Menu 178 6.1.8 Menu Events 179 6.1.9 Loading Menu 180 from Menu Resources 6.2 Menu Effects 181 6.2.1 Customizing the Menu 181 6.2.2 Simulating UC Web Effects Menu 184 6.2.3 QuickContactBadge and Contact Menu 189 6.3 Summary 192 Chapter 7 Friendly Interaction - Information Reminders (Dialog Boxes, Toasts and Notifications) 193 7.1 Basic Usage of Dialog Boxes 193 7.1.1 Dialog Box 193 with 2 Buttons (Confirm/Cancel). 7.1.2 Dialog Box 195 with 3 Buttons (Override/Ignore/Cancel). 7.1.3 Simple List Dialog Box 196 7.1.4 Radio List Dialog Box 198 7.1.5 Multi-Select List Dialog Box 199 7.1.6 Progress Dialog Box 201 7.1.7 Login Dialog Box 205 7.1.8 Using Activity Hosting Dialog 207 7.2 Advanced Applications of Dialog Boxes 209 7.2.1 Preventing Button Clicking to Close Dialog Box 209 7.2.2 Changing the Display Position of the Dialog Box 213 7.2.3 Inserting Images in Dialog Button and Content Text 215 7.2.4 Changing the Transparency of the Dialog Box 216 7.3 Toast 217 7.3.1 Basic Usage of Toast 217 7.3.2 Toast 218 that never closes 7.3.3 Using PopupWindow to Simulate Toast Prompt Infobox 221 7.4 Notification 221 7.4.1 Displaying Notification Information on the Status Bar 222 7.4.2 Clearing Action of Notification 224 7.4.3 Persistent Notification 225 7.4.4 Customizing Notifications 226 7.5 Summary 227 Chapter 8 Mobile Information Warehouse - Data Storage 228 8.1 Read and write key-value pairs: SharedPreferences 228 8.1.1 Basic Usage of SharedPreferences 228 8.1.2 Storage Location and Format of Data 229 8.1.3 Accessing Complex Types of Data 230 8.1.4 Setting Access Permissions for Data Files 233 8.1.5 Activity:PreferenceActivity 234 can be saved 8.2 File Storage 238 8.2.1 openFileOutput and openFileInput methods 238 8.2.2 Reading and Writing Files in SD Card 239 8.2.3 Principle of SAX Engine Reading XML Files 241 8.2.4 Converting XML Files to Java Objects 242 8.2.5 File Compression (Jar, Zip) 245 8.3 SQLite Database 249 8.3.1 SQLite Database Management Tools 249 8.3.2 SQLiteOpenHelper Class and Automatic Upgrade Database 251 8.3.3 Data Binding with SimpleCursorAdapter Class 252 8.3.4 Operating the Database on the SD Card 255 8.3.5 Publishing Databases with Applications 256 8.3.6 In-Memory Database 257 8.4 Summary 258 Chapter 9 Windows in Android - Activity 259 9.1 Calling Activity 259 in other programs 9.1.1 Direct Dial 259 9.1.2 Passing the Telephone Number to the Dial-up Program 259 9.1.3 Calling the Dialer Program 260 9.1.4 Browsing the Web 261 9.1.5 Passing E-mail Address 261 to E-mail Client 9.1.6 Sending E-mail 261 9.1.7 Viewing Contacts 262 9.1.8 Displaying the System Settings Interface (Setting the Main Interface,wifiSettings Interface) 263 9.1.9 Starting the Program for Processing Audio 264 9.2 Customizing Activity Action 264 9.3 Advanced Applications of Activity 266 9.3.1 ActivityGroup 266 9.3.2 Customizing Translucent Windows 268 9.3.3 Animation Effects for Switching Between Activities 269 9.4 Summary 270 Chapter 10 Global Events - Broadcast 271 10.1 What is Broadcasting 271? 10.2 Receiving System Broadcasts 272 10.2.1 SMS Interception 272 10.2.2 Registering the Broadcast Receiver with Code 274 10.2.3 Priority of Broadcast Receiver 275 10.2.4 Incoming and Outgoing Calls Intercept 276 10.2.5 Capturing Screen Hibernation and Wake 280 10.2.6 Automatic Operation 281 at Startup 10.2.7 Displays the current level of the mobile phone battery 282 10.3 Sending Broadcasts 284 10.4 Verifying that the broadcast receiver is registered with 285 10.5 Summary 286 Chapter 11 Cross-Application Data Sources - Content Provider 287 11.1 The Role of Content Provider 287 11.2 Obtaining System Data 288 11.2.1 Reading Contact Information 288 11.2.2 Viewing Received SMS 290 11.3 Customizing Content Provider 291 11.3.1 Querying City Information 291 11.3.2 Adding Access to Content Provider 297 11.4 Summary 298 Chapter 12 Everything for the User - Service Basics and Examples 299 12.1 Service Basics 299 12.1.1 Service Lifecycle 299 12.1.2 Binding Activity and Service 302 12.1.3 Boot Service 305 at Boot 12.1.4 Determining whether a Service is registered with 306 12.1.5 Determining whether a Service has started 307 12.2 Cross-Process Access (AIDL Service) 308 12.2.1 What is AILDL Service 308? 12.2.2 Steps to Establish an AIDL Service 308 12.2.3 Establishing AIDEL Services 308 12.2.4 AITL Services for Delivering Complex Data 312 12.2.5 AIDL and Automatic Hang Up 317 12.3 Summary 319 Chapter 13 Doing a Good Job in Application Bridges: Networks and Communications 320 13.1 WebView Control 320 13.1.1 Browsing Web with WebView Control 320 13.1.2 Loading HTML Code with WebView Control 322 13.2 Accessing HTTP Resources 324 13.2.1 Submitting HTTP GET and HTTP POST Requests 324 13.2.2 HttpURLConnection class 326 13.2.3 Uploading Files 327 13.3 Client Socket 330 13.3.1 Connecting to the Server 331 13.3.2 Scan the server for open port 331 13.3.3 Sending and Receiving Data 333 13.3.4 Obtain the IP address assigned to the mobile phone by the wireless route 334 13.3.5 Setting Socket Option 335 13.4 Server Socket 339 13.4.1 Implementation of Mobile Phone Server 339 13.4.2 Utilizing Sockets to Communicate Between Applications 340 13.5 Bluetooth Communication 342 13.5.1 Introduction to Bluetooth 342 13.5.2 Turning Bluetooth Devices on and Off 343 13.5.3 Searching for Bluetooth Devices 344 13.5.4 Bluetooth Data Transmission 346 13.6 Summary 351 Chapter 14 Cool Your App - Multimedia Development 352 14.1 Music 352 14.1.1 Playing Music 352 14.1.2 Recording 353 14.2 Video 354 14.2.1 Playing Video Using VideoView 354 14.2.2 Playing Video Using SurfaceView 355 14.2.3 Recording Video 357 14.3 Camera 357 14.3.1 Calling the Camera Function of the System 358 14.3.2 Custom Photo Function 359 14.4 Ringtones 364 14.5 Summary 366 Chapter 15 2D Game Development 367 15.1 Drawing the Canvas of the Game 367 15.1.1 Implementing Animation Effects on a View 367 15.1.2 Implementing Animation Effects on SurfaceView 371 15.2 Basics of Drawing Graphics 374 15.2.1 Drawing Pixels 374 15.2.2 Drawing Straight Lines 374 15.2.3 Drawing Circles 375 15.2.4 Drawing Arc 375 15.2.5 Drawing Text 376 15.2.6 Drawing Various Figures 376 15.3 Advanced Image Processing Techniques 380 15.3.1 Drawing Bitmaps 380 15.3.2 Transparency of Images 382 15.3.3 Rotating Images 383 15.3.4 Path 384 15.3.5 Shader Rendering Effects 388 15.4 Frame Animation 392 15.4.1 AnimationDrawable and Frame Animation 392 15.4.2 Playing Gif Animation 394 15.5 Tween Animation 397 15.5.1 Moving Tween Animation 397 15.5.2 Scaling Tweens 399 15.5.3 Rotating Tween Animation 402 15.5.4 Transparency Tween Animation 403 15.6 Summary 404 Chapter 16 Interesting Android Apps 405 16.1 Sensor 405 16.1.1 How to Use Sensor 405 16.1.2 Accelerometer 409 16.1.3 Gravity 409 16.1.4 Light Sensor 410 16.1.5 Gyroscope 411 16.1.6 Orientation 411 16.1.7 Other Sensors 412 16.2 Input and Output Techniques 413 16.2.1 Speech Recognition 413 16.2.2 Gesture Input 415 16.2.3 Speech Reading (TTS) 417 16.3 Google Maps 419 16.4 GPS Positioning 423 16.5 Little things on the table 425 16.5.1 AppWidget 425 16.5.2 Shortcuts 431 16.5.3 Real-Time Folder 433 16.6 Apply more gorgeous - Live Wallpaper 435 16.7 Summary 441 Part 3 Advanced Chapter Chapter 17 HTML5 and Mobile Web Development 444 17.1 Introduction to HTML5 444 17.2 HTML5 Wonderful Effects Demonstration 445 17.3 HTML5 Application in Android 447 17.4 HTML5 Canvas 448 17.4.1 Canvas Overview 448 17.4.2 Detect whether the browser supports Canvas 449 17.4.3 Using Canvas 450 in Web Pages 17.4.4 Using Path 452 17.4.5 Setting the Line Style 453 17.4.6 Setting the Fill Type 453 17.4.7 Filling Rectangular Area 454 17.4.8 Using Gradient 454 17.4.9 Stretching Canvas Objects 455 17.4.10 Drawing Text on Canvas 456 17.4.11 Using Shadows 457 17.5 Debugging JavaScript 458 17.6 Summary 459 Chapter 18 Input Method Development 460 18.1 Introduction to Android Input Methods 460 18.2 Control Input Method 461 18.3 Input Method Practice 462 18.3.1 Step 463 of Implementing the Input Method 18.3.2 Writing Input Method Programs 463 18.3.3 Lifecycle of Input Method Services 466 18.3.4 Pre-Enter Text 467 18.3.5 Input Method Settings 467 18.4 Summary 468 Chapter 19 Android OpenGL ES Development Fundamentals 469 19.1 Introduction to OpenGL 469 19.2 What is OpenGL ES 469? 19.3 Polygons 470 19.4 Color 474 19.5 Rotating Triangle 475 19.6 Rotating Cube 477 19.7 Summary 478 Chapter 20 OpenGL ES Cool Effects 479 20.1 Maintaining Balance Rotating Text 479 20.2 Android Robot 482 Swaying Left and Right 20.3 Tangled Rotating Cube 485 20.4 Rotating Cube with Transparent Background 486 20.5 Touch the rotating cube 487 20.6 Combined Rotation Effects of 2D and 3D 489 20.7 Rotating Three-Dimensional Sky 491 20.8 Summary 493 Chapter 21 Android NDK Programming 494 21.1 Introduction to Android NDK 494 21.2 Installing, Configuring, and Testing the NDK Development Environment 495 21.2.1 System and Software Requirements 495 21.2.2 Download and install Android NDK 495 21.2.3 Download and install Cygwin 495 21.2.4 Configuring the Development Environment of the Android NDK 498 21.3 First NDK Program: Hello World 499 21.3.1 Writing and Calling NDK Programs 499 21.3.2 Compiling NDK Programs 501 by Command Line Method 21.3.3 Integrating Android NDK 502 in Eclipse 21.4 Triangles with Changing Backgrounds (NDK for OpenGL ES) 504 21.5 Implementing Ever-Changing 3D Effects Using the NDK OpenGL ES API 507 21.6 Calling Audio API 510 with NDK 21.7 Native Activity 511 21.8 Android NDK Configuration File Detail 513 21.8.1 Android NDK Defined Variables 513 21.8.2 Android NDK Defined Functions 514 21.8.3 Variables Describing Modules 515 21.8.4 Configuring Application.mk File 516 21.9 Summary 516 Chapter 22 Test Driven Development (TDD) 517 22.1 JUnit Test Framework 517 22.2 Testing Activity 517 22.3 Testing Content Provider 521 22.4 Testing Service 523 22.5 Testing Common Class 523 22.6 Summary 525 Part 4 Comprehensive examples Chapter 23 Android Comprehensive Case 1 - Bluetooth Chat 528 23.1 Bluetooth Chat Main Interface 528 23.2 ADDING OPTIONS MENU 530 23.3 Searching and Connecting to Bluetooth Devices 530 23.4 Making the Device Discoverable by Other Bluetooth Devices 533 23.5 Sending and Receiving Chat Messages 533 23.6 Summary 537 Chapter 24 Android Comprehensive Case 2 - Moon Landing (Game) 538 24.1 How to Play the Game 538 24.2 Implementing the Game Interface 539 24.3 Set the game difficulty 540 24.4 Start Game 541 24.5 Controlling the Ship Spitfire 544 24.6 Controlling the Ship to Change the Direction of Flight 544 24.7 Determine whether the spacecraft has successfully landed 545 24.8 Summary 546 Chapter 25 Android Comprehensive Case 3 - Full Keyboard Input Method (Application) 547 25.1 Installing the Input Method 547 25.2 Initialization of Input Method 548 25.3 Responding to Keyboard Actions 549 25.4 Displaying Different Soft Keyboards Based on the Properties of the EditText Control 551 25.5 Summary 553 Chapter 26 Android Comprehensive Case 4 - Snake (Game) 554 26.1 Gameplay 554 26.2 Game Main Interface Design 555 26.3 Controlling the movement of the snake 557 26.4 Summary 560 Chapter 27 Android Comprehensive Case 5 - Sina Weibo Client (Application) 561 27.1 Introduction to Sina Weibo 561 27.1.1 Sina Weibo Client 561 27.1.2 Sina Weibo Opens API 563 27.2 Using Sina Weibo to develop API 563 27.3 Creating and Configuring the Sina Weibo Client Project 564 27.4 Log in to Sina Weibo 564 27.5 Function Button 567 27.6 Weibo 569 showing "My Home" 27.7 Comments on Weibo 572 27.8 Retweet Weibo 573 27.9 Writing Weibo 574 27.10 Summary 576 Chapter 28 Android Comprehensive Case 6 - Smiling FaceLook at it again and again(Game) 577 28.1 Gameplay 577 28.2 Preparing Image Materials 578 28.3 Implementing the Main Interface 578 28.4 Randomly Generate Continuous Viewing Images 580 28.5 Disappearance after two identical images are selected 580 28.6 Limiting Game Time with Timers 581 28.7 Summary 582
document size; 53.2MB Note: This document is for those who need to learn Android development.
Download address;
Links: Tourists, if you want to see the hidden content of this post, please Reply
|