34
Basic Android Tutorial USF’s Association for Computing Machinery

Basic Android Tutorial USF’s Association for Computing Machinery

Embed Size (px)

Citation preview

Page 1: Basic Android Tutorial USF’s Association for Computing Machinery

Basic Android Tutorial

USF’s Association for Computing Machinery

Page 2: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of Tutorial

1. What You Need2. Create the Project3. Overview of Files4. Create the Layout5. Create the Functionality6. Debugging7. Publish App8. Download to Device

Page 3: Basic Android Tutorial USF’s Association for Computing Machinery

What You Need

• Android Studio and Android SDK• Android device and charging cable (Optional)– The emulator can be used, but it is very slow

• OEM USD Drive (For Windows users only)– Only necessary if you are not using the emulator– Follow these instructions

• Resume Information (Optional)– You can just use gibberish until you have a resume

• This image file: USFLogo.png

Page 4: Basic Android Tutorial USF’s Association for Computing Machinery

Create The ProjectNew Project

Page 5: Basic Android Tutorial USF’s Association for Computing Machinery

Create The ProjectName and Domain

• App Name:– “[Yourname]Resume”

• Domain– Normally the

developer’s website– If you don’t have a

website default to: [netid].myweb.usf.edu

Page 6: Basic Android Tutorial USF’s Association for Computing Machinery

Create The ProjectSelect SDK

• Only use Phone and Tablet for now

• The Min SDK affects what features and libraries are available to your app.

Page 7: Basic Android Tutorial USF’s Association for Computing Machinery

Create The ProjectSelect First Activity

Page 8: Basic Android Tutorial USF’s Association for Computing Machinery

Create The ProjectName First Activity

Page 9: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of FilesLayout Files

• Language: XML• Determines the

User Interface

Page 10: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of FilesBackend Files

• Language: Java• Determines the

App’s Behavior

Page 11: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of FilesImage Resource Files

• Contain the images that will be used in your app

• Currently contains nothing, we’ll add an image later

Page 12: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of FilesStrings and Styles

• Strings.xml– Contains the text

associated with each string ID

• Styles.xml– Contains info for

custom themes

Page 13: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of FilesApp Manifest

• Presents essential information to the Android system– Java package name– Activities and Services– Permissions– Min Level of API– Referenced Libraries

Page 14: Basic Android Tutorial USF’s Association for Computing Machinery

Overview of FilesGradle Build File

• Automates many of the build processes for Android Studio

• Contains build info– SDK Version– Dependencies– Build type

Page 15: Basic Android Tutorial USF’s Association for Computing Machinery

Add the ResourcesAdd an Image

1. Download the Image2. Copy/Paste into the drawable folder of your

app– C:\Users\USERNAME\AndroidStudioProjects\

APPNAME\app\src\main\res\drawable

3. Finish

Page 16: Basic Android Tutorial USF’s Association for Computing Machinery

Add the ResourcesAdd Strings

1. Open strings.xml2. Add strings for the

following categories– Contact Info– Education Info– Work Experience– Extracurricular

Activities

• Download Example Here

Page 17: Basic Android Tutorial USF’s Association for Computing Machinery

Add the ResourcesAdd Styles

1. Open styles.xml2. Add styles for the

following categories– Your Name– Section Title– Item Header– Content– Content Holder

• Download Example Here

Page 18: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UILayout Format

1. In Text Editor change “RelativeLayout” to “LinearLayout”

2. Specify orientation– android:orientation="vertical“

3. Remove existing Textview

• Types of Layout– Relative: specify the location

of child objects relative to each other

– Linear: organizes its children into a single horizontal or vertical row

Page 19: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UIAdd Name and Headers

1. Create TextView for your name, with the style “name”

2. Add TextViews for the following categories, with the style “sectionTitle”– Contact Info– Education Info– Work Experience– Extracurricular Activities

1

2

Page 20: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UILayout So Far

Page 21: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UINested Layout and Content

1. Create a vertical Linear Layout underneath “contactTitle”– Use the style “contentHolder”

2. Add TextViews for each of the following, with the style “content”– Address– Email– Phone Number

3. Do this for all the content headers

Page 22: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UILayout So Far

Page 23: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UIAdd an Image

1. Add an ImageView above name

2. Set the source to the drawable image resource we added earlier

Page 24: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UINested Layout and Content

1. Create a vertical Linear Layout underneath “contactTitle”– Use the style “contentHolder”

2. Add TextViews for each of the following, with the style “content”– Address– Email– Phone Number

3. Do this for all the content headers

Page 25: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UIAdd A Button

1. Add a button at the end of the layout.

2. Set the top margin to 50px

3. Set the id to “linkedin”– Or anything really

• Download Layout Example Here

Page 26: Basic Android Tutorial USF’s Association for Computing Machinery

Test it OutSetup your System to Debug

(if using the emulator, skip this)

1. Verify that your application is "debuggable" in your manifest or build.gradle file. – Remember to undo this before

publishing

2. Enable debugging on your device

i. (If Android 3.2 or lower): Settings > Applications > Development

ii. Settings > About phoneiii. Tap Build number seven times. iv. Return to the previous screen

to find Developer options

AndroidManifext.xml

build.gradle (Module: app)

Page 27: Basic Android Tutorial USF’s Association for Computing Machinery

Test it OutSet up your system to detect your device

(if using the emulator, skip this)

• Windows: Follow the instructions here• Mac OS X: It just works. Skip this step.• Ubuntu Linux: You’re over complicating this.

Page 28: Basic Android Tutorial USF’s Association for Computing Machinery

Test it OutConnect Device and Debug

1. Connect device with USB cable– If using emulator: load

it up

2. Run or Debug3. Select your device or

emulator and click OK

Run Debug

Page 29: Basic Android Tutorial USF’s Association for Computing Machinery

Create the UIOh no! It doesn’t scroll!

• Layouts do not scroll on their own. They need a control that contains a scrolling action.

1. Replace the LinearLayout root element with a ScrollView– Be sure to delete the

orientation tag

2. Add a LinearLayout within the ScrollView

3. Change/Add the end tags

.

.

.

Page 30: Basic Android Tutorial USF’s Association for Computing Machinery

Create the FunctionalityButton Click Event

1. Open Resume.java2. Reference Button from the

layout3. Set click listener and handler4. There will be several errors.

To fix, include the following references:– android.widget.Button– android.content.Intent– android.net.Uri

• Download Example Here

4

2

3

Page 31: Basic Android Tutorial USF’s Association for Computing Machinery

Debugging

1. Set a debug point– Click on the vertical bar to

the left of the code– Or, hit Ctrl+F8 with the

line selected

2. Click Debug– Step Over/Next Line: F8– Step Into: F7– Step Out/Return: Shift+F8

Page 32: Basic Android Tutorial USF’s Association for Computing Machinery

Publish App

1. Turn off debugging– ApplicationManifest.xml– build.gradle

2. Sign your Applicationi. Build > Generate Signed

APKii. Create New…iii. Fill in all fieldsiv. Okv. Nextvi. Finish

Page 33: Basic Android Tutorial USF’s Association for Computing Machinery

Publish AppEmail APK file to your device

1. C:\Users\USERNAME\AndroidStudioProjects\APPNAME\app

2. There will be a file ending in .apk3. Email APK file to yourself4. Open email on your android device and

download APK file5. It will ask you to install6. Now you can send your resume app to

everyone you know!

Page 34: Basic Android Tutorial USF’s Association for Computing Machinery

THE END