A Crash Course to Android Mobile Platform

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

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

Android Workshop: Model View Controller ( MVC):

Real-Time Embedded Systems

Embedded Systems Programming - PA8001

INTRODUCTION TO ANDROID

Android UI Development

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

Android for Java Developers Dr. Markus Schmall, Jochen Hiller

Learn about Android Content Providers and SQLite

Mobile Development Lecture 9: Android & RESTFUL Services

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

Vienos veiklos būsena. Theory

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

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

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

Embedded Systems Programming - PA8001

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

Software Practice 3 Today s lecture Today s Task Porting Android App. in real device

Android Application Model I

Introduction to Android Development

Agenda. The Android GUI Framework Introduction Anatomy A real word example Life cycle Findings

Solving an Android Threading Problem

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

Our First Android Application

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

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

Simple Currency Converter

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

EMBEDDED SYSTEMS PROGRAMMING Application Basics

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Development Tutorial. Yi Huang

Mobila applikationer och trådlösa nät, HI1033, HT2012

Applications. Marco Ronchetti Università degli Studi di Trento

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

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

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

Mobila applikationer och trådlösa nät, HI1033, HT2013

Android Beginners Workshop

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

Basic GUI elements - exercises

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Android HelloWorld - Example. Tushar B. Kute,

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Topics of Discussion

Tabel mysql. Kode di PHP. Config.php. Service.php

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

Android Services. Victor Matos Cleveland State University. Services

Created By: Keith Acosta Instructor: Wei Zhong Courses: Senior Seminar Cryptography

Manifest.xml. Activity.java

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

Intents. Your first app assignment

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

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Starting Another Activity Preferences

Getting Started With Android Feature Flags

COMP61242: Task /04/18

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

Android Application Development

Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm

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

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

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels.

M.A.D Assignment # 1

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

App Development for Smart Devices. Lec #18: Advanced Topics

MOBILE CLIENT FOR ONLINE DICTIONARY. Constantin Lucian ALDEA 1. Abstract

Security model. Marco Ronchetti Università degli Studi di Trento

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

User Interface Design & Development

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

else if(rb2.ischecked()) {

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

package import import import import import import import public class extends public void super new this class extends public super public void new

8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?

Interface ใน View class ประกอบด วย

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

Mobile Application Development Android

Notification mechanism

Lecture 14. Android Application Development

CS260 Intro to Java & Android 09.AndroidAdvUI (Part I)

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

Getting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento

This document is downloaded from DR-NTU, Nanyang Technological University Library, Singapore.

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

Stanislav Rost CSAIL, MIT

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

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

Intro to Android Development 3. Accessibility Capstone Dec 10, 2010

Android Development Tutorial

Multiple Activities. Many apps have multiple activities

Interaction with Android

OPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Android DP SDK Integration Guide

Lecture 6: Android XML, Inversion of Control, Timers (Handlers), Activity

Transcription:

Enterprise Application Development using J2EE Shmulik London Lecture #2 A Crash Course to Android Mobile Platform Enterprise Application Development Using J2EE / Shmulik London 2004 Interdisciplinary Center Herzeliza Israel

Context We ve already mentioned the jungle of mobile platforms. For the course exercise J2ME serves us well as it is small and easy to learn with no much background. So a single lecture is enough for the mobile part of the exercises. However we would like to encourage you to look also at more modern platforms such as Android and iphone and maybe use them in the course project. This lecture is just a crash course for the Android platform (mainly an hands-on demo) to motivate you to read further.

Android Architecture

Comparison with J2ME * Top Layer APIs/SPIs Complete Stack Kernel, libs, VM, framework, apps.. Big impact on security & permissions! Very broad scope From a door-knob to PDA Well defined scope A modern mobile phone Many optional APIs not all supported by all devices Little control and interaction with the phone Wide differences and peculiarities between devices Higher requirement from devices Larger common denominator Didn t held up to the judge of time * We are not really comparing apples with apples, different scope, Android came up 7 years after J2ME

Comparison with J2ME Provisioning mostly via service providers Open Market Standalone apps Background possible on some devices but no interaction Naïve UI framework and canvas Testing with Simulator Very simple Ubiquitous Promotes Mash-ups Multi-processed Much richer UI set Open GLE, effects, Testing with Emulator More complex Time will tell

Main Concepts Activity & Views Intents Data Provider Broadcast Intent Service Network

Demo #1

Project Structure

Manifest <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="examples.sidekick"> <application android:label= SideKick" android:icon="@drawable/sidekick"> <activity android:name="mainactivity android:label="sidekick"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> </activity> </application> </manifest>

Layout (main_screen.xml) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <Button android:id="@+id/criticalbutton" android:text="should I?" android:layout_width="100px" android:layout_height="wrap_content" /> /> </LinearLayout>

Activity public class MainActivity extends Activity { public void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.main_screen); Button button = (Button)findViewById(R.id.criticalButton); button.setonclicklistener(new View.OnClickListener() { public void onclick(view view) { toss(); ); ); private void toss() { boolean doit = Math.random() > 0.5; int int message = doit? R.string.possitive : R.string.negative; new new AlertDialog.Builder(this).setTitle(message).create().show();

Resources (strings.xml) <?xml version="1.0" encoding="utf-8"?> <resources> <string name="possitive">yes, you should do do it!</string> <string name="negative">no, I wouldn't do do it!</string> </resources>

Demo Enterprise Application Development Using J2EE / Shmulik London 2004 Interdisciplinary Center Herzeliza Israel

Few things we ll need for the course A simple game skeleton Networking

Simple game skeleton

Simple Game Canvas public class GameView extends View {... // // instance variables public GameView(Context context) { super(context); playerbitmap = BitmapFactory.decodeResource( getresources(), R.drawable.android_32x40); paint = new Paint(); // // for drawing the background protected void ondraw(canvas canvas) { canvas.drawoval(new RectF( // // drawing background getwidth()/2-40, getheight()/2-40, getwidth()/2+40, getheight()/2+40), paint); canvas.drawbitmap(playerbitmap, x, x, y, y, paint);

Simple Game Canvas public class GameActivity extends Activity { private GameView gameview; public void oncreate(bundle bundle) { super.oncreate(bundle); gameview = new GameView(this); setcontentview(gameview); gameview.setontouchlistener(new View.OnTouchListener() { public boolean ontouch(view view, MotionEvent e) e) { gameview.setfigurelocation(e.getx(), e.gety()); gameview.postinvalidate(); return true; );

Simple Game Canvas protected void onstart() { super.onstart(); gameview.setfigurelocation( gameview.getwidth()/2, gameview.getheight()/2);

Http Example

Http Example public class DictionaryActivity extends Activity { private HttpClient client; public void oncreate(bundle bundle) { super.oncreate(bundle); client = new new DefaultHttpClient(); setcontentview(r.layout.dictionary_screen); Button subbutton = (Button)findViewById(R.id.submitButton); subbutton.setonclicklistener(new View.OnClickListener() { public void onclick(view view) { EditText inputfield = (EditText) findviewbyid(r.id.wordfield); String word = inputfield.gettext().tostring(); Runnable task = new new FetchDefinitionTask(word); new new Thread(task, "FetchDefinition").start(); ); );

Http Example class FetchDefinitionTask implements Runnable { private String word; FetchDefinitionTask(String word) { this.word = word; public void run() { String url url = "http://127.0.0.1:8080/dictionary/dictionary"+ "?word= +URLEncoder.encode(word); HttpGet request = new new HttpGet(url); request.addheader("content-type", "text/plain"); try try { HttpResponse response = client.execute(request); if if (response.getstatusline().getstatuscode()!=!= 200) { displayresult( Sorry, failed to to fetch definition. ); return;

Http Example HttpEntity entity = response.getentity(); String body = EntityUtils.toString(entity); displayresult(body); catch (IOException e) e) { Log.e("dictionary", "failed: "+url, e); e); displayresult("sorry, Failed to to fetch definition!"); private void displayresult(final String message) { DictionaryActivity.this.runOnUiThread(new Runnable() { public void run() { TextView resultfield = (TextView)findViewById(R.id.definitionField); resultfield.settext(message); ); );

Http Example <?xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/wordfield" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> /> <Button android:id="@+id/submitbutton" android:text="submit" android:layout_width="100px" android:layout_height="wrap_content" /> /> </LinearLayout> <TextView android:id="@+id/definitionfield" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"/> </LinearLayout>

Http Example <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="dictionary"> <uses-permission android:name="android.permission.internet"/> <application android:label="online-dictionary"> <activity android:name="dictionaryactivity" android:label="online-dictionary"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> </activity> </application> </manifest>

Summary We only gave you a taste of Android, there is much more services, data-providers, OpenGL, Location API, XMPP, Accelerometer And don t forget the other platform you can choose from: iphone, Blackberry, Windows-Mobile