Upon completion of the second part of the lab the students will have:

Similar documents
When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

Creating a Custom ListView

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Android Programming Lecture 2 9/7/2011

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Android HelloWorld - Example. Tushar B. Kute,

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Android Application Development

Android Basics. Android UI Architecture. Android UI 1

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Assignment 1: Port & Starboard

GIT. A free and open source distributed version control system. User Guide. January, Department of Computer Science and Engineering

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

Lab 01 How to Survive & Introduction to Git. Web Programming DataLab, CS, NTHU

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

Android UI Development

ListView Containers. Resources. Creating a ListView

<uses-permission android:name="android.permission.internet"/>

Vienos veiklos būsena. Theory

Topics of Discussion

Our First Android Application

INTRODUCTION TO ANDROID

Tutorial: Getting Started with Git. Introduction to version control Benefits of using Git Basic commands Workflow

Lab Android Development Environment

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

User Interface Design & Development

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

XML Tutorial. NOTE: This course is for basic concepts of XML in line with our existing Android Studio project.

Lab 3. Accessing GSM Functions on an Android Smartphone

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Lab 6: Google Maps Android API v2 Android Studio 10/14/2016

Programming with Android: Introduction. Layouts. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

UI Fragment.

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

GUI Widget. Lecture6

(Cloud9) and to the Remote Repository (GitHub)

Getting Started With Android Feature Flags

Software Revision Control for MASS. Git Installation / Configuration / Use

CS 4330/5390: Mobile Application Development Exam 1

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

CS260 Intro to Java & Android 05.Android UI(Part I)

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Technology Background Development environment, Skeleton and Libraries

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Lab Exercise Git: A distributed version control system

FEEG Applied Programming 3 - Version Control and Git II

Sample Spark Web-App. Overview. Prerequisites

Android Data Binding: This is the DSL you're looking for

Software Development I

Managing Network Configurations with Git and GitLab

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

A short tutorial on Git. Servesh Muralidharan 4 March 2014

Produced by. Mobile Application Development. Eamonn de Leastar

ConstraintLayouts in Android

ListView (link) An ordered collection of selectable choices. key attributes in XML:

Android InsecureBankv2 Usage Guide. InsecureBankv2

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University

A Brief Git Primer for CS 350

MC Android Programming

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Gitlab Setup/Usage by Yifeng Zhu modified by Vince Weaver 30 January 2019

CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing. Lab & Demo 2 (Part 1-2) Hello-Goodbye App Tutorial

Android Programming (5 Days)

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Fragments. Lecture 11

CMSC436: Fall 2013 Week 4 Lab

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Introduction to Version Control with Git

SD Module-1 Android Dvelopment

Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Mobile Programming Lecture 1. Getting Started

Using git for Homework

Mobile Computing Fragments

Code Repository. P Blanchfield

Android Programs Day 5

EMBEDDED SYSTEMS PROGRAMMING Application Basics

Fragment Example Create the following files and test the application on emulator or device.

Programming Android UI. J. Serrat Software Design December 2017

Introduction to Git. Database Systems DataLab, CS, NTHU Spring, 2018

ELET4133: Embedded Systems. Topic 15 Sensors

Getting started with Tabris.js Tutorial Ebook

What is git? Distributed Version Control System (VCS); Created by Linus Torvalds, to help with Linux development;

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

License. Introduction to Version Control with Git. Local Version Control Systems. Why Use Version Control?

CMSC436: Fall 2013 Week 3 Lab

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

CS260 Intro to Java & Android 05.Android UI(Part I)

Technology Background Development environment, Skeleton and Libraries

G E T T I N G S TA R T E D W I T H G I T

Transcription:

ETSN05, Fall 2017, Version 2.0 Software Development of Large Systems Lab 2 1. INTRODUCTION The goal of lab 2 is to introduce students to the basics of Android development and help them to create a starting point for the projects. The lab is divided two parts. After the first part of the lab the students will be able to: Create a bare minimum Android project Run an Android app on an emulator Version the project using git Upon completion of the second part of the lab the students will have: Cloned a project from git Performed an HTTP request from the Network project Experience and knowledge on: Creating a simple user interface Creating new Android Activity Using ListView Using AsyncTasks Using action listeners Proper XML layout practices 2. APP SKELETON In this part the students will create a skeleton for their projects, run it an emulator and version it using git. 2.1 Creating the skeleton A. Create a new Android project following the instruction on the page (adhere to the rules below to avoid problems caused by permission restrictions on the school computers): https://developer.android.com/training/basics/firstapp/creating-project.html a. In step 2 in the link above, change the project location to C:\Users\your_username\AndroidProjects. If you don t see the Users directory in the dialog, click on the Show hidden files and directories button, marked in the figure below:

B. After step 6, there will be errors in the project due to the lab computers not having ConstraintLayout installed. To fix them do the following: In the file explorer (left part of the Android Studio interface), open the file build.gradle(marked 1 in the figure above) In the file, remove the line: compile 'com.android.support.constraint:constraint-layout:+' Open file activity_main.xml and remove lines associated with ContraintLayout so that the code looks like this:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.elt13wch.myapplication.mainactivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello World!" /> </LinearLayout> i. Make the project (Ctrl + F9) to get rid of the rest of the errors C. Make sure to read the descriptions of the most important files generated in part A. Try to locate them in the using the Android Studio GUI. 2.2 Running the app on an emulator A. Go to https://developer.android.com/training/basics/firstapp/running-app.html scroll down to section titled Run on the Emulator and follow the instructions in order to create a virtual device. You might have problems installing new devices and system images on the lab computers. In that case pick from the already installed ones. B. Run the app on the emulator as described in the previous link. C. Demonstrate to the lab leader that you successfully ran the app. 2.3 Versioning the app with git A. Click on the VCS menu and choose Enable Version Control Integration. This will automatically create a local git repository and ignore files that shouldn t be versioned. B. Go to directory C:\Users\<Your username>\androidprojects\<your app name>\, right-click anywhere and choose Git Bash Here. This will open a Git Bash console. C. Set your email and username using the following commands git config user.email your@email.com git config user.name your_name D. Create an initial commit using command the following commands git add * git add.gitignore.idea/ git commit -m Initial commit

E. Create a remote repository on either GitHub, BitBucket or GitLab. In this lab manual BitBucket will be used. F. Copy the repository address (It s not the URL in the address bar, the repository address should be written somewhere on the repository web page). Make sure you select the HTTPS option if you don t have SSH setup for your BitBucket account. G. Back in the Git Bash Console, run the following commands to add your remote git remote add origin https://<your_bb_account>@bitbucket.org/<your_bb_account>/<projec t_name>.git git push -u origin master H. Enter your BitBucket credentials to push your changes to remote repository I. If you have done everything correctly, your project code should now be visible on your remote repository. J. Demonstrate to the lab leader that you successfully pushed your initial commit to the remote repository. 3. ANDROID DEVELOPMENT In this part of the lab, you will clone a project from git and use it to practice Android programming. If you don t know how to do one of the exercises below, refer to the lab preparation document. 3.1 Clone the network app A. Close the skeleton app project in Android Studio IDE if you haven t already by clicking (File Close Project).

B. Click Check out project from Version Control and choose Git from the dropdown menu. C. In the Git Repository URL type https://jammaster@bitbucket.org/jammaster/etsn05- network.git D. In the parent directory, choose directory C:\Users\your_username\AndroidProjects. Follow the instructions from 2.1 Aa if you have trouble navigating to that directory. E. Press the Clone button and wait for the repository to be cloned. F. Launch the app on a virtual device to make sure the cloning was successful. 3.2 Basic UI work A. Add a Button to the starting Activity s layout. You can find the Button s text in the strings.xml resource file. You can do this both using the Android Studio layout editor or in the XML code. Don t forget to give it an ID that you can use in the next step. B. Register an onclicklistener for the newly created button. This will be used later. 3.3 Creating a new Activity A. In this example the other Activity s skeleton is already created, as well as its layout resource. To finish, add the activity to the manifest using the following code: <activity android:name=".listdevicesactivity" /> B. Back in the actionlistener from the previous step, get the current value of the EditText field, and pass it to the new Activity when starting it. C. In the ListDevicesActivity s oncreate method, get the value that has been passed to it and store it in a variable. D. Run the app and make sure that a new Activity is started. 3.4 Creating a layout from scratch A. Add a TextView and a ListView to the ListDevicesActivity s layout. Don t forget to give them both ID s. B. Initialise the listview and adapter members of ListDevicesActivity. Use android.r.layout.simple_list_item_1 built-in item layout when constructing the adapter. Set adapter as listview s adapter. C. In the ListDevicesActivity s oncreate method, set the TextView s text to the message that has been passed to the Activity. You already have this message after exercise 3.3 C. D. Run the app and make sure that the message is passed and displayed properly.

3.5 Updating the list A. Override Activity s lifecycle method onresume. Create a new GetDevicesTask object and implement its abstract method, presentresults so that it adds all the devices contained in the argument results to the adapter. To make it easier, first write new GetDevicesTask().execute(); then click somewhere on the erroneous line, press Alt+Enter choose Implement methods. Then press okay. B. Before the request to the backend can be performed, the app has to declare that it uses internet in order to gain permissions. Add the following permission to the app s manifest, above the application tag: <uses-permission android:name="android.permission.internet" /> C. Run the app to test if it works as intended. Try starting the ListDevicesActivity, then pressing the home button and then getting back to the app through the recent apps button. Is the list still correct? D. Try to understand how the GetDevicesTask class works E. Answer the following questions: a. Which files contain code that defines how the user interface of the two Activities is going to look like? b. Could the UI definitions be written directly in the Java code? Why/why not? c. Why does the GetDevicesTask need to extend AsyncTask? Why can t it be run in the onresume method directly? d. What are lifecycle methods and how are they useful? F. Demonstrate to the lab leader that your app works and that you answered the questions. 3.6 [OPTIONAL] Making the list presentable A. In order to make the device list pleasant to look at, create a new class called DeviceAdapter that extends ArrayAdapter<DeviceBean>. B. After making your DeviceAdapter extend ArrayAdapter<DeviceBean>, Android Studio will complain. Resolve the error by creating a constructor that matches super. You can do this automatically by left-clicking on the erroneous line, pressing Alt+Enter and choosing the desired solution. C. Remove the resource parameter from the constructor. As a parameter to the superconstructor, use R.layout.item_device. Also save context in a member variable inside the class DeviceAdapter. D. Override the getview method and add the following lines to it: LayoutInflater inflater = (LayoutInflater) context.getsystemservice(context.layout_inflater_service);

E. The above lines will create a view that contains UI components of a better list item. Inspect what the list items look like in layout/item_device.xml F. Fill the UI components with their proper data. If you re having trouble with this exercise, the essential parts of it are used as an example in the preparation documents for the lab. G. Back in ListDevicesActivity, replace ArrayAdapter<DeviceBean> with DeviceAdapter in the oncreate method. You might need to modify the presentresults method to work with the new Adapter. H. Run the app and see if it works.