万本电子书0元读

万本电子书0元读

顶部广告

Android Programming for Beginners电子书

售       价:¥

11人正在读 | 0人评论 9.8

作       者:John Horton

出  版  社:Packt Publishing

出版时间:2015-12-31

字       数:440.0万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn all the Java and Android skills you need to start making powerful mobile applications About This Book Kick-start your Android programming career, or just have fun publishing apps to the Google Play marketplace A first-principles introduction to Java, via Android, which means you’ll be able to start building your own applications from scratch Learn by example and build three real-world apps and over 40 mini apps throughout the book Who This Book Is For Are you trying to start a career in programming, but haven’t found the right way inDo you have a great idea for an app, but don’t know how to make it a realityOr maybe you’re just frustrated that “to learn Android, you must know java.” If so, Android Programming for Beginners is for you. You don’t need any programming experience to follow along with this book, just a computer and a sense of adventure. What You Will Learn Master the fundamentals of coding Java for Android Install and set up your Android development environment Build functional user interfaces with the Android Studio visual designer Add user interaction, data captures, sound, and animation to your apps Manage your apps’ data using the built-in Android SQLite database Find out about the design patterns used by professionals to make top-grade applications Build, deploy, and publish real Android applications to the Google Play marketplace In Detail Android is the most popular OS in the world. There are millions of devices accessing tens of thousands of applications. It is many people's entry point into the world of technology; it is an operating system for everyone. Despite this, the entry-fee to actually make Android applications is usually a computer science degree, or five years’ worth of Java experience. Android Programming for Beginners will be your companion to create Android applications from scratch—whether you’re looking to start your programming career, make an application for work, be reintroduced to mobile development, or are just looking to program for fun. We will introduce you to all the fundamental concepts of programming in an Android context, from the Java basics to working with the Android API. All examples are created from within Android Studio, the official Android development environment that helps supercharge your application development process. After this crash-course, we’ll dive deeper into Android programming and you’ll learn how to create applications with a professional-standard UI through fragments, make location-aware apps with Google Maps integration, and store your user’s data with SQLite. In addition, you’ll see how to make your apps multilingual, capture images from a device’s camera, and work with graphics, sound, and animations too. By the end of this book, you’ll be ready to start building your own custom applications in Android and Java. Style and approach With more than 40 mini apps to code and run, Android Programming for Beginners is a hands-on guide to learning Android and Java. Each example application demonstrates a different aspect of Android programming. Alongside these mini apps, we push your abilities by building three larger applications to demonstrate Android application development in context.
目录展开

Android Programming for Beginners

Table of Contents

Android Programming for Beginners

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

Why Android?

But is this book for me?

What this book covers

What you need for this book

Windows

Mac OS X

Linux

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. The First App

How Java and Android work together

The Android API

Java is object-oriented

What exactly is Android?

The development environment

A note to the existing developers who use Eclipse

The JDK

What if I already have Java?

Installing the JDK

Setting up Android Studio

What makes an Android app

Android resources

The structure of Android's Java code

Android packages

Our first Android app

Creating the project

A note on version controlling

Deploying and testing the app

Deploying to an emulator

Deploying to a real Android device

FAQ

Summary

2. Java – First Contact

Examining the log output

Exploring the project assets and code

Examining the layout file

Improving our app and deploying again

Modifying the UI

Meet Java

Java comments

Sending messages

Writing our first Java code

Writing our own Java methods

Examining the log output

FAQ

Summary

3. Exploring Android Studio

The Android Studio guided tour

Parts of the UI

The console

More console features

The project explorer

Transforming the editor into a design studio

E1 – the Preview toolbar

E2 – exploring the palette

E3 – the layout preview

E4 – the Component Tree

E5 – the Properties window

E6 – text and design view tabs

The project folder and file structure

FAQ

Summary

4. Designing Layouts

Exploring Android UI design

Structure of a UI design

Configuring and using widgets

Widget properties

Setting the size

Sizing using dp

Sizing fonts using sp

Determining size with wrap or match

Using padding and margin

Using the layout_weight property

Using gravity

More properties

Experimenting with widgets

Containing widgets in layouts

RelativeLayout

RelativeLayout in action

Using LinearLayout

Summary

5. Real-World Layouts

Building a real-world UI

Creating a tablet emulator

List-detail layout with ScrollView and LinearLayout

Designing a form with RelativeLayout

Summary

6. The Life and Times of an Android App

Introduction to the Android lifecycle

A simplified explanation of the Android lifecycle

Lifecycle phases – what we need to know

Lifecycle phases – what we need to do

The lifecycle demonstration app

Some other overridden methods

The structure of Java code – revisited

Summary

7. Coding in Java Part 1 – Variables, Decisions, and Loops

Java is everywhere

Syntax and jargon

More code comments

Storing and using data with variables

Types of variables

Primitive types

Reference types

Variable declaration

Variable initialization

Changing values in variables with operators

Expressing yourself demo app

Decisions

Indenting our code

More operators

If they come over the bridge, shoot them

Else do this instead

Switching to make decisions

The Switch Demo app

Repeating code with loops

While loops

Breaking out of a loop

Continue

Do while loops

For loops

Loops demo app

Summary

8. Coding in Java Part 2 – Methods

Methods revisited

The method structure

Modifiers

Return types

The name of a method

Parameters

Working in the method body

Using methods – demo apps

Real-world methods

Exploring method overloading

Scope and variables revisited

FAQ

Further reading

Summary

9. Object-Oriented Programming

Important memory management warning

Introducing OOP

What is OOP exactly?

Encapsulation

Polymorphism

Inheritance

Why do it like this?

A class recap

Taking a look at the code for a class

The class implementation

Declaring, initializing, and using an object of the class

The basic classes mini app

More things we can do with our first class

Remember that encapsulation thing?

Controlling class use with access modifiers

Class access in a nutshell

Controlling variable use with access modifiers

Variable access summary

Methods have access modifiers too

A method access summary

Accessing private variables with getters and setters

Setting up our objects with constructors

Static methods

Encapsulation and static methods mini app

OOP and inheritance

The inheritance mini app

Polymorphism

Abstract classes

Interfaces

FAQ

Summary

10. Everything's a Class

All Android UI elements are classes too

Reintroducing references

A quick break to throw out the trash

Stack and heap – a quick summary

So, how does this heap thing help me?

Using Button and TextView widgets from our layout

Inner and anonymous classes

FAQ

Summary

11. Widget Mania

Exploring Android UI objects

Declaring and initializing objects

Widget news flash

Exploring the palette

EditText

ImageView

Radio button and group

Anonymous classes

A switch widget

CheckBox

WebView

Date & Time

Android permissions and Marshmallows

Pre-Marshmallow permissions

Marshmallow permissions

The permission solution used in this book

The Widget exploration mini app

Setting up the widget exploration project and UI

Coding the widget exploration app

Summary

12. Having a Dialogue with the User

Dialog windows

The dialog demo mini project – introducing chaining

About the Note To Self app

Using naming conventions and String resources

How to get the Note To Self code

What we will do and when we will do it

What the user can do

Building the project and gathering resources

Downloading the images

Preparing the String resources

Coding the Note class

Implementing the dialog designs

Coding the dialog boxes

Coding the DialogNewNote class

Coding the DialogShowNote class

Showing our new dialogs

Adding a + icon to the action bar

Summary

13. Handling and Displaying Arrays of Data

A random diversion

Handling large amount of data with arrays

Arrays are objects

A simple array example mini app

Getting dynamic with arrays

A dynamic array example

Entering the nth dimension with arrays

A multidimensional array mini app

Array out of bounds exceptions

ArrayLists

The enhanced for loop

Arrays and ArrayLists are polymorphic

ListView and BaseAdapter

The problem with displaying lots of widgets

The solution

How to use ListView and BaseAdapter

Inner classes revisited

FAQ

Summary

14. Handling and Displaying Notes in Note To Self

Note To Self continued

Updating onCreate and preparing the UI

Creating a list item for ListView

Improvements in Note To Self

Persistence

Animation

Sound FX

Problems with the design of the code

FAQ

Summary

15. Android Intent and Persistence

Good Intents

Switching Activity

Passing data between activities

Adding a settings page to the Note To Self app

Creating SettingsActivity

Designing the Settings screen's layout

Enabling the user to switch to the Settings screen

Persisting data with SharedPreferences

Making the Note To Self app's settings persist

Coding the SettingsActivity class

Coding the MainActivity class

Specifying a parent Activity

More advanced persistence

What is JSON?

Java exceptions - try, catch, and finally

Backing up user data in Note To Self

FAQ

Summary

16. UI Animations

Animations in Android

Designing cool animations in XML

Fading in and out

Movement

Scaling or stretching

Controlling the duration

Rotating animations

Repeating animations

Combining animation properties with a set tag

Instantiating animations and controlling them with Java code

More animation features

Listeners

Animation interpolators

The Animations Demo app – introducing SeekBar

Laying out the animation demo

Coding the XML animations

Wiring up the Animations Demo app in Java

Adding animations to Note To Self

Defining the animations in XML

Controlling the animations in Java

FAQ

Summary

17. Sound FX and Supporting Different Versions of Android

Supporting multiple versions of Android

Detecting the current Android version

The SoundPool class

Building SoundPool the new way and the old way

Loading sound files into memory

Playing a sound

Stopping a sound

Introducing the Spinner widget

Making sound FX

Laying out Sound Demo UI

Coding the Sound Demo app

Sound FX touches to Note To Self

Deleting a note – introducing OnLongClick

FAQ

Summary

18. Design Patterns, Fragments, and the Real World

Introducing the model-view-controller pattern

The model

The view

The controller

The imperfections of Note To Self revisited

Android design guidelines

Real-world apps

The device detection mini app

Configuration qualifiers

Using configuration qualifiers – mini app

The configuration qualifier's summary

Fragments

Fragments have a lifecycle too

onCreate

onCreateView

onAttach and onDetach

onStart, onPause, and onStop

Managing Fragments with FragmentManager

Our first working Fragment mini app

Fragment reality check

FAQ

Summary

19. Using Multiple Fragments

Using singletons for the model layer

Inter-Fragment communications – interfaces revisited

The dual-Fragment address book mini app

Getting started

Alias resources

The NameAndAddress class

Creating the communication interface

Explaining the structure of the onListItemSelected method

Explaining the code that starts a new Activity

Explaining the code when the detail Fragment is already present

What do we need to do?

Creating the AddressDetailFragment class and layout

Coding PortraitDetailActivity and the layout

FAQ

Summary

20. Paging and Swiping

Building an image gallery/slider app

Implementing the layout

Coding the PagerAdapter class

Coding the MainActivity class

Running the gallery app

Building a Fragment pager/slider app

Coding the SimpleFragment class

fragment_layout

Coding the MainActivity class

The activity_main layout

Running the Fragment slider app

Summary

21. Navigation Drawer and Where It's Snap

Introducing the navigation drawer

The Where it's snap app

Preparing the resources

Placeholder code for three Fragments

Coding the MainActivity class and layout

Switching between Fragments

Setting up the drawer

Handling the back button

Summary

22. Capturing Images

Capturing images using the camera

The capturing images mini app

Adding the camera permission to the manifest

Defining a simple layout

Coding the MainActivity class

Running the Simple Photo app

Where it's snap – coding the capture Fragment

Creating the layout for the capture Fragment

Coding the capture Fragment

Testing the capture Fragment

Summary

23. Using SQLite Databases in Our Apps

Database 101

What is a database?

What is SQL?

What is SQLite?

The SQL syntax primer

The SQLite example code

Creating a table

Inserting data into the database

Retrieving data from the database

Updating the database structure

The Android SQLite API

SQLiteOpenHelper and SQLiteDatabase

Building and executing queries

Database cursors

The database mini app

Implementing the layout

Coding the database class

Coding MainActivity

Running the mini app

Summary

24. Adding a Database to Where It's Snap

The Photo class

Handling the SQLite database

Saving a new photo from the capture fragment

Displaying a photo from the database

Preparing the View layout

Coding the ViewFragment class

Coding the communications interface

Coding TitlesFragment

Coding TagsFragment

Coding the fragment communications in MainActivity

Running the app so far

Summary

25. Integrating Google Maps and GPS Locations

Global Positioning System

Where in the world – the GPS mini app

Where in the world – implementing a simple layout

Coding the Where in the world mini app

Running the Where in the world mini app

The Google Maps mini app

Preparing to connect to Google Maps

Acquiring an API key

Installing the Google Play services API

Coding the maps_activity layout

Coding MapsActivity

Running the Simple Map app

Summary

26. Upgrading SQLite – Adding Locations and Maps

Adding locations and maps to Where it's Snap

Updating the database

Adding member variables to represent location data

Updating the database version

Adding code in onUpgrade to upgrade the database for existing users

Updating the database creation code in onCreate for new users

Updating the addPhoto method to handle GPS coordinates

Updating the Photo class

Updating CaptureFragment

Updating ViewFragment

Adding location permissions

Testing the new map feature

Summary

27. Going Local – Hola!

The Localization mini app

Preparing the layout

Preparing the first strings.xml file

Making the app multilingual with the second strings.xml file

Adding a third language

Running the app

Localizing the Where it's snap app

Summary

28. Threads, Touches, Drawing, and a Simple Game

Threads

Problems with threads

Drawing with canvas and paint

The Android coordinate system

Android Canvas demo app

Handling touches

A simple game engine

Building a simple game of Pong

Adding sound files to the project

Coding the ball

Coding the paddle

Coding MainActivity

Coding SurfaceView

Coding the update method

Coding the draw method

Lock the screen orientation and make it full-screen

Running the game

Pong enhancements

Summary

29. Publishing Apps

Preparing to publish

Creating an app icon

Preparing the required resources

Building the publishable APK file

Publishing the app

Marketing

More to see

Summary

30. Before You Go

What next

Keep reading

GitHub

StackOverflow

Android user forums

For further study

Make some apps!

gamecodeschool.com

Goodbye and thank you

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部