Introduction to Android Programming 19.3.2013. Content Basic environmental structure Building a simple app Debugging.

Slides:



Advertisements
Similar presentations
Android Terminology Component: Activities, content providers, broadcast receivers, and services that together make up an application Activity: A single.
Advertisements

All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Who Am I And Why Am I Here I’m professor Stephen Fickas in CIS – you can call me Steve. I have a research group that works with mobile devices (since 1995!)
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
Android Tutorial Larry Walters OOSE Fall References This tutorial is a brief overview of some major concepts…Android is much richer and more complex.
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Android Application Development 2013 PClassic Chris Murphy 1.
Better reference the original webpage :
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Introducing the Sudoku Example
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
CS5103 Software Engineering Lecture 08 Android Development II.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Chapter 2: Simplify! The Android User Interface
ANDROID – INTERFACE AND LAYOUT L. Grewe. Interfaces: Two Alternatives Code or XML  You have two ways you can create the interface(s) of your Application.
Basic Android Tutorial USF’s Association for Computing Machinery.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
CE Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running.
Eclipse Tutorial Barrett Summer Scholars 2011 Sustainable Engineering: Learning to Engineer Truly Green Products.
Presented By: Muhammad Tariq Software Engineer Android Training course.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
User Interfaces: Part 1 (View Groups and Layouts).
Configuring Android Development Environment Nilesh Singh.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Creating an Example Android App in Android Studio Activity lifecycle & UI Resources.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
1 Android Introduction Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
ANDROID APPLICATION DEVELOPMENT. ANDROID DEVELOPMENT DEVELOPER.ANDROID.COM/INDEX.HTML THE OFFICIAL SITE FOR ANDROID DEVELOPERS. PROVIDES THE ANDROID SDK.
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Resources & Android Manifest Калин Кадиев Astea Solutions AD.
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CHAPTER 1 part 1 Introduction. Chapter objectives: Understand Android Learn the differences between Java and Android Java Examine the Android project.
Android Programming.
Chapter 2: Simplify! The Android User Interface
Lab7 – Appendix.
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Open Handset Alliance.
Android Application Development 1 6 May 2018
Android N Amanquah.
Adapting to Display Orientation
Android Introduction Hello World.
Development-Introduction
ITEC535 – Mobile Programming
תכנות ב android אליהו חלסצ'י.
Mobile Device Development
Anatomy of an Android Application
Android SDK & App Development
MultiUni Trần Vũ Tất Bình
CS5103 Software Engineering
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Presentation transcript:

Introduction to Android Programming

Content Basic environmental structure Building a simple app Debugging

Basic environmental structure Create a very simple application Examine its structure Run it on a real device Run it on the emulator

Create a new Android project (File > New > Android Application)

Name that appears on device Directory name Class to automatically create Java package Android version

Set your project: Project Name: Hello World Build Target: Select Android 2.1 Application Name: Hello World Package Name: com.android.test Create Activity: HelloWorld Press "Finish"

Project Components src – your source code gen – auto-generated code (usually R.java) Included libraries Resources – Drawables (like.png images) – Layouts – Values (like strings) Manifest file

Source code Auto-generated code UI layout String constants Configuration

Now you have your project created let's write some code! Your code is located in a file called HelloWorld.java in the src folder. Your screen layout file is main.xml in the layout directory.

Project files

1 public class HelloAndroid extends Activity { 2 /** Called when the activity first created. */ 4 public void onCreate(Bundle savedInstanceState) 5 { 6 super.onCreate(savedInstanceState); 7 setContentView(R.layout.main); 8 } 9 } HelloWorld.java Sourcecode Inherit from the Activity Class Set the layout of the view as described in the main.xml layout

Hello World modify HelloWorld.java 12

XML file Used to define some of the resources – Layouts (UI) – Strings – Manifest file res/layout: contains layout declarations of the app, UIs are built according to the layout file

Elements and layouts ImageButton EditText CheckBox Button RadioButton ToggleButton RatingBar

DatePicker TimePicker Spinner AutoComplete Gallery MapView WebView Elements and layouts

Types of Layouts Linear Layout – It organizes controls vertical or horizontal fashion Relative Layout, – It organizes controls relative to one another. Table Layout – A grid of made up of rows and columns, where a cell can display a view control Frame Layout – Frame layouts are the normal layout of choice when you want to overlap different views stacked on top the other.

Layout

Open main.xml in Layout mode

select main.xml to view/edit the xml markup

Drag a button on to layout

Linear Layout Layout 21 main.xml <LinearLayout xmlns:android= android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" /> TextView, display static text A reference to String resource ‘hello’

1 2 3 Hello World, HelloAndroid! 4 5 Hello, Android 6 strings.xml In res/values strings.xml Promotes good programming style Strings are just one kind of ‘Value’

Manifest File Contains characteristics about your application NEED to specify it in manifest file – Have more than one Activity in app, – Services and other components too – Important to define permissions and external libraries, like Google Maps API

Manifest File – Adding an Activity

1 2 <manifest 3 xmlns:android=" 4 package="edu.upenn.cis542" 5 android:versionCode="1" 6 android:versionName="1.0"> 7 <application 8 9 <activity android:name=".HelloAndroid" <action 13 android:name="android.intent.action.MAIN" /> 14 <category 15 android:name="android.intent.category.LAUNCHER"/> AndroidManifest.xml

Run Hello World Select HelloWorld Project, Run->Run as->Android Application ADT will start a proper AVD and run HelloWorld app on it 26

You may receive "Android AVD Error" if you have not setup an android emulator device. Select yes to setup a new Android Virtual Device Select "New"

Create new Android Virtual Device Name: Android 2.1 Target: Android 2.1 API Level 7 SD card Size: 4000 MiB Rest as default settings

Press "Create AVD". Be patient it will take a minute to create your new AVD. Select your new AVD and run your application. To get it running…

Emulator

On Phone Should be enabled on phone to use developer features In the main apps screen select: → Settings → Applications → Development → USB debugging (needs to be checked)

How to Debug Log.v(tag, message); Window > Show View > Other > Android > LogCat To show a pop-up window: Toast.makeText( getApplicationContext(), message, Toast.LENGTH_LONG).show();

Logcat Information Log.e("MyTag", "Error message with my own tag"); Log.w("dalvikvm", "VM Warning message"); Log.d("MyTag", "Debug message"); Log.i("MainActivity","Information message"); Log.v("MyTag", "Verbose message"); Log.f(“Fail", "What a Terrible Failure");

Useful sources Android Official Site Android SDK, Tutorial, Concepts and API docs Android Development Community 30 Days Android Apps Development 36