[PDF] [PDF] Kotlin / Android Studio 30 Development - eBookFrenzycom

Creating an Example Android App in Android Studio 11 3 Converting from Java to Kotlin An Android Studio Layout Editor ConstraintLayout Tutorial



Previous PDF Next PDF





[PDF] GETTING STARTED WITH KOTLIN: A RESOURCE GUIDE

convert Android apps from Java to Kotlin, while still teaching the essentials of Kotlin as well • Kotlin Koans: This tutorial offers a series of self-guided exercises to 



[PDF] Kotlin / Android Studio 30 Development - eBookFrenzycom

Creating an Example Android App in Android Studio 11 3 Converting from Java to Kotlin An Android Studio Layout Editor ConstraintLayout Tutorial



[PDF] Kotlin android tutorial ppt - Squarespace

By 2017, Android app developers almost exclusively used the Java 6 to work with this tutorial, you will learn Kotlin by working with an application that allows 



[PDF] Android Programming In Kotlin Starting With An App - 50000+ Free

Easy Kotlin tutorial for Android for beginners - Android Android Programming In Kotlin: Starting With An App shows you how common tasks are done in 



[PDF] Android Development with Kotlin

tools, and you will be able to develop an Android application entirely in Kotlin and often it is presented at the beginning of most Android tutorials Code that

[PDF] kotlin tutorial android developer

[PDF] kotlin tutorial android for beginners pdf

[PDF] kotlin tutorial android javatpoint

[PDF] kotlin tutorial android pdf

[PDF] kotlin tutorial android studio pdf

[PDF] kotlin tutorial android tutorialspoint

[PDF] kotlin version

[PDF] kpmg balance sheet

[PDF] kpmg central login

[PDF] kpmg clara website login

[PDF] kpmg fintech 100 2019

[PDF] kraken x52 instructions

[PDF] kraken x52 manual amd

[PDF] ks cna registry lookup

[PDF] ks medicaid enrollment status

Kotlin / Android Studio 3.0

Development Essentials

Android 8 Edition

Kotlin / Android Studio 3.0 Development Essentials - Android 8 Edition © 2017 Neil Smyth / Payload Media, Inc. All Rights Reserved.

?is book is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly

prohibited. All rights reserved.

?e content of this book is provided for informational purposes only. Neither the publisher nor the author o?ers

any warranties or representation, express or implied, with regard to the accuracy of information contained in

this book, nor do they accept any liability for any loss or damage arising from any errors or omissions.

?is book contains trademarked terms that are used solely for editorial purposes and to the bene?t of the

respective trademark owner. ?e terms used within this book are not intended as infringement of any trademarks.

Rev: 1.0

i

Contents

Table of Contents

1. Introduction ........................................................................

1.1 Downloading the Code Samples ........................................................................

...............................1

1.2 Firebase Essentials Book Now Available ........................................................................

..................2

1.3 Feedback ........................................................................

1.4 Errata........................................................................

.....2

2. Setting up an Android Studio Development Environment .......................................................................3

2.1 System Requirements ........................................................................

2.2 Downloading the Android Studio Package ........................................................................

.............3

2.3 Installing Android Studio ........................................................................

2.3.1 Installation on Windows ........................................................................

.....................................4

2.3.2 Installation on macOS ........................................................................

2.3.3 Installation on Linux ........................................................................

2.4 ?e Android Studio Setup Wizard ........................................................................

............................5

2.5 Installing Additional Android SDK Packages ........................................................................

.........6

2.6 Making the Android SDK Tools Command-line Accessible .........................................................8

2.6.1 Windows 7........................................................................

2.6.2 Windows 8.1 ........................................................................

2.6.3 Windows 10 ........................................................................

2.6.4 Linux ........................................................................

2.6.5 macOS ........................................................................

2.7 Updating Android Studio and the SDK ........................................................................

.................10

2.8 Summary ........................................................................

3. Creating an Example Android App in Android Studio ........................................................................

...11

3.1 Creating a New Android Project ........................................................................

.............................11

3.2 De?ning the Project and SDK Settings ........................................................................

..................12

3.3 Creating an Activity ........................................................................

3.4 Modifying the Example Application ........................................................................

.......................14

3.5 Reviewing the Layout and Resource Files ........................................................................

..............20

3.6 Summary ........................................................................

4. A Tour of the Android Studio User Interface ........................................................................

..................23

4.1 e Welcome Screen ........................................................................

4.2 ?e Main Window ........................................................................

4.3 ?e Tool Windows ........................................................................

4.4 Android Studio Keyboard Shortcuts ........................................................................

......................28

4.5 Switcher and Recent Files Navigation ........................................................................

....................28

4.6 Changing the Android Studio ?eme ........................................................................

....................29

4.7 Summary ........................................................................

5. Creating an Android Virtual Device (AVD) in Android Studio .............................................................31

5.1 About Android Virtual Devices ........................................................................

..............................31

5.2 Creating a New AVD ........................................................................

5.3 Starting the Emulator ........................................................................

ii

Table of Contents

5.4 Running the Application in the AVD ........................................................................

.....................33

5.5 Run/Debug Con?gurations........................................................................

......................................35

5.6 Stopping a Running Application ........................................................................

.............................36

5.7 AVD Command-line Creation ........................................................................

................................37

5.8 Android Virtual Device Con?guration Files ........................................................................

.........38

5.9 Moving and Renaming an Android Virtual Device .....................................................................38

5.10 Summary ........................................................................

6. Using and Con?guring the Android Studio AVD Emulator ..................................................................41

6.1 e Emulator Environment ........................................................................

.....................................41

6.2 ?e Emulator Toolbar Options ........................................................................

................................41

6.3 Working in Zoom Mode ........................................................................

6.4 Resizing the Emulator Window........................................................................

...............................43

6.5 Extended Control Options ........................................................................

6.5.1 Location ........................................................................

6.5.2 Cellular ........................................................................

6.5.3 Battery ........................................................................

6.5.4 Phone ........................................................................

6.5.5 Directional Pad ........................................................................

6.5.6 Microphone ........................................................................

6.5.7 Fingerprint ........................................................................

6.5.8 Virtual Sensors ........................................................................

6.5.9 Settings........................................................................

6.5.10 Help ........................................................................

6.6 Drag and Drop Support ........................................................................

6.7 Con?guring Fingerprint Emulation ........................................................................

.......................45

6.8 Summary ........................................................................

7. Testing Android Studio Apps on a Physical Android Device ..................................................................47

7.1 An Overview of the Android Debug Bridge (ADB) .....................................................................47

7.2 Enabling ADB on Android based Devices ........................................................................

............47

7.2.1 macOS ADB Con?guration ........................................................................

..............................48

7.2.2 Windows ADB Con?guration ........................................................................

..........................49

7.2.3 Linux adb Con?guration ........................................................................

...................................50

7.3 Testing the adb Connection ........................................................................

.....................................50

7.4 Summary ........................................................................

8. ?e Basics of the Android Studio Code Editor ........................................................................

................53

8.1 e Android Studio Editor........................................................................

8.2 Splitting the Editor Window ........................................................................

....................................55

8.3 Code Completion ........................................................................

8.4 Statement Completion ........................................................................

8.5 Parameter Information ........................................................................

8.6 Parameter Name Hints ........................................................................

8.7 Code Generation ........................................................................

8.8 Code Folding ........................................................................

8.9 Quick Documentation Lookup ........................................................................

...............................60

8.10 Code Reformatting........................................................................

8.11 Finding Sample Code ........................................................................

8.12 Summary ........................................................................

iii

Table of Contents

9. An Overview of the Android Architecture ........................................................................

......................63

9.1 e Android Soware Stack ........................................................................

....................................63

9.2 ?e Linux Kernel ........................................................................

9.3 Android Runtime - ART ........................................................................

9.4 Android Libraries ........................................................................

9.4.1 C/C++ Libraries ........................................................................

9.5 Application Framework ........................................................................

9.6 Applications ........................................................................

9.7 Summary ........................................................................

10. ?e Anatomy of an Android Application ........................................................................

......................67

10.1 Android Activities ........................................................................

10.2 Android Intents ........................................................................

10.3 Broadcast Intents ........................................................................

10.4 Broadcast Receivers ........................................................................

10.5 Android Services ........................................................................

10.6 Content Providers ........................................................................

10.7 ?e Application Manifest ........................................................................

10.8 Application Resources ........................................................................

10.9 Application Context ........................................................................

10.10 Summary ........................................................................

11. An Introduction to Kotlin ........................................................................

11.1 What is Kotlin? ........................................................................

11.2 Kotlin and Java ........................................................................

11.3 Converting from Java to Kotlin ........................................................................

.............................71

11.4 Kotlin and Android Studio ........................................................................

....................................72

11.5 Experimenting with Kotlin ........................................................................

....................................72

11.6 Semi-colons in Kotlin ........................................................................

11.7 Summary ........................................................................

12. Kotlin Data Types,Variables and Nullability ........................................................................

.................75

12.1 Kotlin Data Types ........................................................................

12.1.1 Integer Data Types ........................................................................

12.1.2 Floating Point Data Types ........................................................................

..............................76

12.1.3 Boolean Data Type ........................................................................

12.1.4 Character Data Type ........................................................................

12.1.5 String Data Type ........................................................................

12.1.6 Escape Sequences ........................................................................

12.2 Mutable Variables ........................................................................

12.3 Immutable Variables ........................................................................

12.4 Declaring Mutable and Immutable Variables ........................................................................

......78

12.5 Data Types are Objects ........................................................................

12.6 Type Annotations and Type Inference ........................................................................

.................79

12.7 Nullable Type ........................................................................

12.8 ?e Safe Call Operator ........................................................................

12.9 Not-Null Assertion ........................................................................

12.10 Nullable Types and the let Function ........................................................................

...................81

12.11 ?e Elvis Operator ........................................................................

12.12 Type Casting and Type Checking ........................................................................

.......................83

12.13 Summary ........................................................................

13. Kotlin Operators and Expressions ........................................................................

.................................85

13.1 Expression Syntax in Kotlin ........................................................................

...................................85

13.2 ?e Basic Assignment Operator ........................................................................

............................85

13.3 Kotlin Arithmetic Operators ........................................................................

.................................85

13.4 Augmented Assignment Operators ........................................................................

......................86

13.5 Increment and Decrement Operators ........................................................................

..................86

13.6 Equality Operators ........................................................................

13.7 Boolean Logical Operators ........................................................................

....................................87

13.8 Range Operator ........................................................................

13.9 Bitwise Operators ........................................................................

13.9.1 Bitwise Inversion ........................................................................

13.9.2 Bitwise AND ........................................................................

13.9.3 Bitwise OR ........................................................................

13.9.4 Bitwise XOR ........................................................................

13.9.5 Bitwise Le? Shi? ........................................................................

13.9.6 Bitwise Right Shi? ........................................................................

13.10 Summary ........................................................................

14. Kotlin Flow Control ........................................................................

14.1 Looping Flow Control ........................................................................

14.1.1 ?e Kotlin for-in Statement ........................................................................

.............................93

14.1.2 ?e while Loop ........................................................................

14.1.3 ?e do ... while loop ........................................................................

14.1.4 Breaking from Loops ........................................................................

14.1.5 ?e continue Statement ........................................................................

...................................96

14.1.6 Break and Continue Labels ........................................................................

.............................96

14.2 Conditional Flow Control ........................................................................

......................................97

14.2.1 Using the if Expressions ........................................................................

.................................97

14.2.2 Using if ... else ... Expressions ........................................................................

........................98

14.2.3 Using if ... else if ... Expressions ........................................................................

.....................98

14.2.4 Using the when Statement ........................................................................

..............................99

14.3 Summary ........................................................................

15. An Overview of Kotlin Functions and Lambdas ........................................................................

.........101

15.1 What is a Function? ........................................................................

15.2 How to Declare a Kotlin Function ........................................................................

......................101

15.3 Calling a Kotlin Function ........................................................................

.....................................102

15.4 Single Expression Functions ........................................................................

................................102

15.5 Local Functions ........................................................................

15.6 Handling Return Values ........................................................................

15.7 Declaring Default Function Parameters ........................................................................

.............103

15.8 Variable Number of Function Parameters ........................................................................

........103

15.9 Lambda Expressions ........................................................................

15.10 Higher-order Functions ........................................................................

.....................................105

15.11 Summary ........................................................................

16. ?e Basics of Object Oriented Programming in Kotlin ......................................................................107

16.1 What is an Object? ........................................................................

16.2 What is a Class? ........................................................................

v

Table of Contents

16.3 Declaring a Kotlin Class ........................................................................

16.4 Adding Properties to a Class........................................................................

................................108

16.5 De?ning Methods ........................................................................

16.6 Declaring and Initializing a Class Instance ........................................................................

........108

16.7 Primary and Secondary Constructors ........................................................................

................108

16.8 Initializer Blocks ........................................................................

16.9 Calling Methods and Accessing Properties ........................................................................

.......111

16.10 Custom Accessors ........................................................................

16.11 Nested and Inner Classes ........................................................................

...................................112

16.12 Summary ........................................................................

17. An Introduction to Kotlin Inheritance and Subclassing .....................................................................115

17.1 Inheritance, Classes and Subclasses ........................................................................

....................115

17.2 Subclassing Syntax ........................................................................

17.3 A Kotlin Inheritance Example ........................................................................

.............................116

17.4 Extending the Functionality of a Subclass ........................................................................

.........117

17.5 Overriding Inherited Methods ........................................................................

............................118

17.6 Adding a Custom Secondary Constructor........................................................................

.........119

17.7 Using the SavingsAccount Class ........................................................................

.........................119

17.8 Summary ........................................................................

18. Understanding Android Application and Activity Lifecycles .............................................................121

18.1 Android Applications and Resource Management ...................................................................121

18.2 Android Process States ........................................................................

18.2.1 Foreground Process ........................................................................

18.2.2 Visible Process ........................................................................

18.2.3 Service Process ........................................................................

18.2.4 Background Process ........................................................................

18.2.5 Empty Process ........................................................................

18.3 Inter-Process Dependencies ........................................................................

...............................123

18.4 ?e Activity Lifecycle ........................................................................

18.5 ?e Activity Stack ........................................................................

18.6 Activity States ........................................................................

18.7 Con?guration Changes ........................................................................

18.8 Handling State Change ........................................................................

18.9 Summary ........................................................................

19. Handling Android Activity State Changes........................................................................

...................127

19.1 e Activity Class ........................................................................

19.2 Dynamic State vs. Persistent State ........................................................................

.......................129

19.3 ?e Android Activity Lifecycle Methods ........................................................................

...........129

19.4 Activity Lifetimes ........................................................................

19.5 Disabling Con?guration Change Restarts ........................................................................

.........132

19.6 Summary ........................................................................

20. Android Activity State Changes by Example ........................................................................

...............133

20.1 Creating the State Change Example Project ........................................................................

......133

20.2 Designing the User Interface ........................................................................

...............................134

20.3 Overriding the Activity Lifecycle Methods ........................................................................

.......135

20.4 Filtering the Logcat Panel........................................................................

.....................................138

20.5 Running the Application ........................................................................

20.6 Experimenting with the Activity ........................................................................

.........................139

20.7 Summary ........................................................................

21. Saving and Restoring the State of an Android Activity .......................................................................143

quotesdbs_dbs17.pdfusesText_23