EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Similar documents
EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

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

EMBEDDED SYSTEMS PROGRAMMING Android Services

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


Mobile Software Development for Android - I397

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

PROGRAMMING APPLICATIONS DECLARATIVE GUIS

EMBEDDED SYSTEMS PROGRAMMING Application Basics

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

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

Basic GUI elements - exercises

Android - JSON Parser Tutorial

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

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

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

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

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Intents. Your first app assignment

Android - Widgets Tutorial

Android Programs Day 5

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

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


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

Create Parent Activity and pass its information to Child Activity using Intents.

Arrays of Buttons. Inside Android

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

APPENDIX CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE

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

EMBEDDED SYSTEMS PROGRAMMING Android NDK

Android Application Development. By : Shibaji Debnath

ANDROID PROGRAMS DAY 3

else if(rb2.ischecked()) {

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"

Introduction to Android Development

// MainActivity.java ; Noah Spenser; Senior Design; Diabetic Breathalyzer

Topics of Discussion

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

Simple Currency Converter

Vienos veiklos būsena. Theory

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

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

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

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

EMBEDDED SYSTEMS PROGRAMMING Android NDK

SD Module-1 Android Dvelopment

Multiple Activities. Many apps have multiple activities

Manifest.xml. Activity.java

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

Tutorial: Setup for Android Development

使用 TensorFlow 設計矩陣乘法計算並轉移執行在 Android 上 建國科技大學資管系 饒瑞佶 2017/8

COMP61242: Task /04/18

Android UI Development

Produced by. Mobile Application Development. Eamonn de Leastar

Android Workshop: Model View Controller ( MVC):

User Interface Development in Android Applications

android-espresso #androidespresso

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

Fragments. Lecture 11

M.A.D Assignment # 1

Android/Java Lightning Tutorial JULY 30, 2018

Developing For Android

Data Persistence. Chapter 10

Learn about Android Content Providers and SQLite

ELET4133: Embedded Systems. Topic 15 Sensors

Dynamically Create Admob Banner and Interstitial Ads

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Understanding Intents and Intent Filters

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

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

Android Services. Victor Matos Cleveland State University. Services

Android JSON Parsing Tutorial

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

LifeStreet Media Android Publisher SDK Integration Guide

Notification mechanism

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

Serious Gaming. Technical manual. This document is a collection of the code and installation process

Time Picker trong Android

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

APPENDIX. Application Store Admin. build.gradle. app/build.gradle

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks.

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

South Africa

Android Basics. Android UI Architecture. Android UI 1

An Overview of the Android Programming

EMBEDDED SYSTEMS PROGRAMMING Android NDK

Android Navigation Drawer for Sliding Menu / Sidebar

UI (User Interface) overview Supporting Multiple Screens Touch events and listeners

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

05. RecyclerView and Styles

1 카메라 1.1 제어절차 1.2 관련주요메서드 1.3 제작철차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다.

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

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

SMART VEHICLE TRACKING APPLICATION

Chapter 8 Positioning with Layouts

Getting Started With Android Feature Flags

Lecture 14. Android Application Development

Transcription:

EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Tip: Switching UIs

THE PROBLEM How to switch from one UI to another Each UI is associated with a distinct class that controls it Solution shown: two UIs, hence two classes. A button in each UI triggers the switch to the other UI

THE TIP Two classes derived from Activity The UIs associated with the classes are defined declaratively, hence there are two XML layout files The two classes invoke each other via intents

INTENTS (1/3) Intent: abstract request for an action to be performed Explicit intent: requires an exact component (e.g., a class) to perform the operation Implicit intent: does not specify a class, but includes enough information for the system to determine which of the available components is to be invoked (intent resolution)

INTENTS (2/3) The intent resolution process may find more than one suitable component: in this case, the final choice is up to the user Action requested: display a location on the map

INTENTS (3/3) Intents have a flexible (and complex) syntax; http://developer.android.com/guide/components/inten ts-filters.html provides full details To invoke a specific component (such as an activity), simply build an intent specifying a context of the application package implementing the component, the component class

CODE (1/6) Source files: Activity1.java, Activity2.java Layouts: activity_1.xml, activity_2.xml

CODE (2/6) activity_1.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="it.unipd.dei.esp1516.switchactivity.activity1"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="this is Activity 1" android:id="@+id/textview" /> <Button android:text="next" android:id="@+id/button01" android:layout_width="200dp" android:layout_height="wrap_content" android:textsize="18sp" android:layout_below="@+id/textview" android:layout_alignparentleft="true" android:layout_alignparentstart="true"> </Button> </RelativeLayout>

CODE (3/6) activity_2.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"... <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="this is Activity 2" android:id="@+id/textview2" /> <Button android:id="@+id/button02" android:layout_width="200dp" android:layout_height="wrap_content" android:text="previous" android:textsize="18sp" android:layout_below="@+id/textview2" android:layout_alignparentleft="true" android:layout_alignparentstart="true"> </Button> <CheckBox android:id="@+id/plain_cb" android:layout_width="200px" android:layout_height="wrap_content" android:text="check me" android:layout_centervertical="true" android:layout_centerhorizontal="true" /> </RelativeLayout>

CODE (4/6) Activity1.java package it.unipd.dei.esp1516.switchactivity; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; public class Activity1 extends AppCompatActivity { /** Called when the activity is first created. */ @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_1); Button next = (Button) findviewbyid(r.id.button01); next.setonclicklistener(new View.OnClickListener() { public void onclick(view view) { Intent myintent = new Intent(view.getContext(), Activity2.class); startactivityforresult(myintent, 0); } }); } }

CODE (5/6) Activity2.java package it.unipd.dei.esp1516.switchactivity; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; public class Activity2 extends AppCompatActivity { /** Called when the activity is first created. */ @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_2); } } Button next = (Button) findviewbyid(r.id.button02); next.setonclicklistener(new View.OnClickListener() { public void onclick(view view) { Intent intent = new Intent(); setresult(result_ok, intent); finish(); } });

CODE (6/6) Both activities should be declared in the AndroidManifest.xml file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.unipd.dei.esp1516.switchactivity"> <application android:allowbackup="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".activity1"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".activity2"/> </application> </manifest>

LAST MODIFIED: APRIL 1, 2016 COPYRIGHT HOLDER: CARLO FANTOZZI (FANTOZZI@DEI.UNIPD.IT) LICENSE: CREATIVE COMMONS ATTRIBUTION SHARE-ALIKE 3.0