ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Android Development:
Build Android App from Scratch
Taufan Er?yanto, ST.
A one day workshop of Android Development at Phetchaburi Rajabhat University, Thailand.
In collaboration with Gunadarma University and Phetchaburi Rajabhat University.
Founder of pongodev.com,
mobile application developer
and the man who responsible
to deliver the app with
beautiful user interface and
insure that it generates many
download with marketing
strategy.
About
taufan@pongodev.com
twitter.com/taufan20
linkedin.com/in/taufan20
portfolio
Crowdfunding mobile-
based application that
allows users raise funds
for humanity and
environmental activities.
Donation can be done via
smartphone credit and
transfer.
http://donasia.org
What do you know
about Android?
1 billion Android
population.
Horace dediu
1.43 million apps on
Google Play in 2014.
appFigures
268 billion times downloads
and generate revenue $77
billion in 2017.
Gartner
Available in all devices,
smartphone, watch, tv,
and car.
Android Development
Tools
1. Java Development Kit
download: bit.ly/JDKandroid
2. Android Studio and SDK Tools
download: bit.ly/AnStudio
Creating New Project
1. Select Start a new Android Studio
Project on Welcome window.
2. Type application name and company
domain.
3. Select Device Type and Minimum SDK.
4. Select Blank Activity in Activity type.
5. Name your ?rst activity and layout ?le.
Understand the
Project Structure
1. Android project consist of manifest,
java, res, and Gradle directories.
2. Activity works as a page in application.
Located in java directory.
3. The ?rst method that will be executed
when app run is onCreate().
4. Every activity has layout ?le as its user
interface. located in res/layout directory.
5. To connect layout and activity,
setContentView() must be de?ned.
6. Every activity created must be registered
to AndroidManifest.xml.
Creating Android
Emulator
1. Open AVD Manager via Tools >
Android.
2. Select Create Virtual Device¡­ button.
3. Select device type and screen
resolution.
4. Select Android version.
5. Type emulator name.
6. Select the emulator name and click
Launch icon.
Running Android
Project on Emulator
1. Select Run > Run ¡®app¡¯.
2. Select Launch emulator and emulator name.
Or select Choose a running device if you have
running emulator.
Running Android Project
on Android Device
1. On Android device, select Settings >
Developer Options. Enable USB Debugging.
Note: Android 4.2 and newer go to Settings > About
phone and tap Build number seven times.
2. Connect Android device to the computer
via usb cable.
3. Select Run > Run ¡®app¡¯.
2. Select Choose a running device and
device name.
Note: some device require a driver from its factory to be
installed on the computer.
Creating User
Interface
1. Open your xml layout ?le in layout
directory.
2. Drag widget on Palette section to
device screen on the right side.
3. Con?gure widget properties via properties
window on the right bottom corner of the window.
Note: important properties are id, layout_width, and
layout_height.
Manipulating Widget
1. Open activity ?le that use
activity_main.xml layout in java directory.
2. Create objects of the widgets in activity
?le that you want to manipulate.
3. Connect the objects with widget id in
xml layout inside onCreate() method.
4. Add event handling to button object.
5. manipulate your widget when button
click inside onClick() method.
Creating To Do List
App
1. Modify the user interface as seen above.
Consist of EditText, Button, and ListView.
2. Create objects of EditText, Button, and
ListView in activity ?le.
3. Connect the objects with widget id in
xml layout.
4. Create ArrayAdapter object and
ArrayList variable above onCreate() method.
5. De?ne adapter parameter and set it to
list object using setAdapter().
6. Add button event handling to add data
to the list.
7. Run the project to see the result.
Integrating SQLite
Database to Android
Project
1. Create new directory under app/src/main
directory via window explorer. name it as assets.
2. Create database to store data inside
assets directory using sqlitebrowser.
Note: database of to do list app can be download at bit.ly/dbTodo
and sqlitebrowser can be download at bit.ly/sqliteAndroid.
3. Create new java ?le inside app/java/
package.name.
4. Name it as DBHelper.
Note: Download DBHelper.java ?le at bit.ly/DBHelper
and copy the code to your DBHelper.java.
5. De?ne database path, database name,
table name and ?elds.
Note: SQLiteOpenHelper is used for creating, opening, and upgrading
database. SQLiteDatabase is used for communicating data of database.
6. Create object of DBHelper class and
ArrayList variable in Activity ?le.
7. Connect dbhelper object with it class and call
createDataBase() and openDataBase() method.
8. Create displayData() method before closing
bracket to display data from database with
getAllNotes() method.
9. And call displayData() method after
openDataBase() method.
10. Call addNote() and displayData() method
inside button event handling to add data to
databse and display them after added.
11. Run the project to see the
result.
12. Add new arraylist variable
to store note id.
13. Do not forget to clear ids and
add ids in displayData() method.
14. Create list event handling to
delete note with item on list click.
15. Call removeNote() method to remove data
from database and displayData() method to re-
display data on the list.
16. Run the project again to
see the result.
What do you need to
know next to mastering
Android development?
Fragments
Material Design
Hardware
Integration
Multiple Screen
Support
Connect to
Web Services
¨CJoel Spolsky, Stack Exchange
Nothing works better than just
improving your product.

More Related Content

Android Development: Build Android App from Scratch