Android Programs Day 5

Size: px
Start display at page:

Download "Android Programs Day 5"

Transcription

1 Android Programs Day 5 //Android Program to demonstrate the working of Options Menu. 1. Create a New Project. 2. Write the necessary codes in the MainActivity.java to create OptionMenu. 3. Add the oncreateoptionsmenu() in mainactivity.java after oncreate(). public boolean oncreateoptionsmenu(menu menu) super.oncreateoptionsmenu(menu); CreateMenu(menu); return super.oncreateoptionsmenu(menu); 4. Add oncreatemenu(menu) user-defined function. menu.add(0, 0, 0, "Item 1"): Arguements: 1: Group ID 2: Item ID 3: Order ID 4: Item Names private void CreateMenu(Menu menu) MenuItem mnu1 = menu.add(0, 0, 0, "Item 1"); MenuItem mnu2 = menu.add(0, 1, 1, "Item 2"); 5. Add onoptionsitemselected(menuitem). Any operation on items, will call this function and handle the events. public boolean onoptionsitemselected(menuitem item) return MenuChoice(item); 6. Add on MenuChoice(MenuItem) user-defined function. private boolean MenuChoice(MenuItem item)

2 switch (item.getitemid()) case 0: //Code Goes Here case 1: //Code Goes Here return false; 7. Run the code and test the working of OptionMenu. //MainActivity.java: import android.content.intent; import android.net.uri; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.toast; public class MainActivity extends AppCompatActivity protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public boolean oncreateoptionsmenu(menu menu) super.oncreateoptionsmenu(menu); createmenu(menu); return super.oncreateoptionsmenu(menu); private void createmenu(menu menu) MenuItem menu1 = menu.add(0, 0, 0, "View A Contact"); MenuItem menu2 = menu.add(0, 1, 1, "Edit A Contact"); MenuItem menu3 = menu.add(0, 2, 2, "Dial A Contact"); MenuItem menu4 = menu.add(0, 3, 3, "View All");

3 public boolean onoptionsitemselected(menuitem item) return menuchoice(item); private boolean menuchoice(menuitem item) switch(item.getitemid()) case 0: Intent obj = new Intent(Intent.ACTION_VIEW); obj.setdata(uri.parse("content://contacts/people/1")); startactivity(obj); case 1: Intent obj1 = new Intent(Intent.ACTION_EDIT); obj1.setdata(uri.parse("content://contacts/people/1")); startactivity(obj1); case 2: Intent obj2 = new Intent(Intent.ACTION_DIAL); obj2.setdata(uri.parse("tel: ")); startactivity(obj2); case 3: Intent obj3 = new Intent(Intent.ACTION_VIEW); obj3.setdata(uri.parse("content://contacts/people/")); startactivity(obj3); //activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ibmsap.test_optionmenu.mainactivity"> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content"

4 android:text="hello World" " tools:layout_constraintleft_creator="1" tools:layout_constrainttop_creator="1" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" tools:layout_constraintright_creator="1" android:layout_margintop="117dp" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout>

5 //Android Program to demonstrate the working of Context Menu. 1. Create a New Project. 2. Add a Button in the UI. Write the necessary codes in the MainActivity.java to create ContextnMenu. 3. Add a Listener to the Button by writing the following code. Button btn = (Button)findViewById(R.id.button); btn.setoncreatecontextmenulistener(this); 4. Add the oncreatecontextmenu() in mainactivity.java after oncreate(). public void oncreatecontextmenu(contextmenu menu, View v,contextmenu.contextmenuinfo menuinfo) super.oncreatecontextmenu(menu, v, menuinfo); CreateMenu(menu); 5. Add on CreateMenu(menu) user-defined function. menu.add(0, 0, 0, "Item 1"): Arguements: 1: Group ID 2: Item ID 3: Order ID 4: Item Names private void CreateMenu(Menu menu) MenuItem mnu1 = menu.add(0, 0, 0, "Item 1"); MenuItem mnu2 = menu.add(0, 1, 1, "Item 2"); 6. Add oncontextitemselected(menuitem). Any operation on items, will call this function and handle the events. public boolean oncontextitemselected(menuitem item) return MenuChoice(item); 7. Add on MenuChoice(MenuItem) user-defined function.

6 private boolean MenuChoice(MenuItem item) switch (item.getitemid()) case 0: //Code Goes Here case 1: //Code Goes Here return false; 7. Run the code and test the working of ContextMenu. //MainActivity.java: import android.content.intent; import android.net.uri; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.contextmenu; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.button; import android.widget.toast; public class MainActivity extends AppCompatActivity Button btn; protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btn = (Button)findViewById(R.id.button); btn.setoncreatecontextmenulistener(this); public void oncreatecontextmenu(contextmenu menu, View v, ContextMenu.ContextMenuInfo menuinfo) super.oncreatecontextmenu(menu, v, menuinfo); createmenu(menu);

7 private void createmenu(menu menu) MenuItem menu1 = menu.add(0, 0, 0, "View A Contact"); MenuItem menu2 = menu.add(0, 1, 1, "Edit A Contact"); MenuItem menu3 = menu.add(0, 2, 2, "Dial A Contact"); MenuItem menu4 = menu.add(0, 3, 3, "View All"); public boolean oncontextitemselected(menuitem item) return menuchoice(item); private boolean menuchoice(menuitem item) switch(item.getitemid()) case 0: Intent obj = new Intent(Intent.ACTION_VIEW); obj.setdata(uri.parse("content://contacts/people/1")); startactivity(obj); case 1: Intent obj1 = new Intent(Intent.ACTION_EDIT); obj1.setdata(uri.parse("content://contacts/people/1")); startactivity(obj1); case 2: Intent obj2 = new Intent(Intent.ACTION_DIAL); obj2.setdata(uri.parse("tel: ")); startactivity(obj2); case 3: Intent obj3 = new Intent(Intent.ACTION_VIEW); obj3.setdata(uri.parse("content://contacts/people/")); startactivity(obj3); //activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android=" xmlns:app=" xmlns:tools="

8 android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ibmsap.test_optionmenu.mainactivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="context Menu" tools:layout_constrainttop_creator="1" tools:layout_constraintright_creator="1" tools:layout_constraintbottom_creator="1" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintright_torightof="parent" tools:layout_constraintleft_creator="1" app:layout_constraintleft_toleftof="parent" app:layout_constrainttop_totopof="parent" app:layout_constrainthorizontal_bias="0.417" app:layout_constraintvertical_bias="0.498" /> </android.support.constraint.constraintlayout>

9 //Android Program to demonstrate the Menu Creation using XML File. 1. Create a new project. 2. Create a Directory "menu" in /res folder. 3. Create a Menu resource file in /res/menu folder and name it as menu.xml 4. Add few <item> as buttons. //menu.xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=" <item android:id="@+id/menu1" android:title="menu 1" /> <item android:id="@+id/menu2" android:title="menu 2" /> <item android:id="@+id/menu3" android:title="menu 3" /> </menu> 5. Add oncreateoptionsmenu(menu) and use MenuInflater object to populate the menu isng menu.xml file. public boolean oncreateoptionsmenu(menu menu) MenuInflater menuinflater = getmenuinflater(); menuinflater.inflate(r.menu.menu, menu); return super.oncreateoptionsmenu(menu);

10 6. Add onoptionsitemselected(menuitem). Any operation on items, will call this function and handle the events. public boolean onoptionsitemselected(menuitem item) return MenuChoice(item); //MainActivity.java: import android.content.intent; import android.net.uri; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; public class MainActivity extends AppCompatActivity protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public boolean oncreateoptionsmenu(menu menu) MenuInflater obj = getmenuinflater(); obj.inflate(r.menu.menu, menu); return super.oncreateoptionsmenu(menu); public boolean onoptionsitemselected(menuitem item) return menuchoice(item); private boolean menuchoice(menuitem item) switch(item.getitemid()) case R.id.Menu1: Intent obj = new Intent(Intent.ACTION_VIEW); obj.setdata(uri.parse("content://contacts/people/1")); startactivity(obj);

11 case R.id.Menu2: Intent obj1 = new Intent(Intent.ACTION_EDIT); obj1.setdata(uri.parse("content://contacts/people/1")); startactivity(obj1); case R.id.Menu3: Intent obj2 = new Intent(Intent.ACTION_DIAL); obj2.setdata(uri.parse("tel: ")); startactivity(obj2); case R.id.Menu4: Intent obj3 = new Intent(Intent.ACTION_VIEW); obj3.setdata(uri.parse("content://contacts/people/")); startactivity(obj3); //activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ibmsap.test_menuxml.mainactivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello World!" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout> //menu.xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:app="

12 xmlns:android=" <item android:title="view A Contact"/> <item android:id="@+id/menu2" android:title="edit A Contact"/> <item android:id="@+id/menu3" android:title="dial A Contact"/> <item android:id="@+id/menu4" android:title="view All Contacts"/> </menu>

13 //Android Program to demonstrate the Sub-Menu Creation using XML File. 1. Create a new project. 2. Create a Directory "menu" in /res folder. 3. Create a Menu resource file in /res/menu folder and name it as menu.xml 4. To add Sub menu follow these steps. i. Create an <item> tag in the menu.xml file. ii. Create a <menu> tag inside the <item> tag. This will act as Main menu 1. iii. Create few <item> tags in the <menu> tag. Give proper id and titles. These will act as Sub-menu 1. iv. Repeat the steps i to iv to create one more sub-menu. //menu.xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=" <item android:id="@+id/mainmenu1" android:title="main Menu 1"> <menu android:title="sub Menu1"> <item android:id="@+id/menu1" android:title="view A Contact"/> <item android:id="@+id/menu2" android:title="edit A Contact"/> </menu> </item> </menu>

14 5. Add oncreateoptionsmenu(menu) and use MenuInflater object to populate the menu isng menu.xml file. public boolean oncreateoptionsmenu(menu menu) MenuInflater menuinflater = getmenuinflater(); menuinflater.inflate(r.menu.menu, menu); return super.oncreateoptionsmenu(menu); 6. Add onoptionsitemselected(menuitem). Any operation on items, will call this function and handle the events. public boolean onoptionsitemselected(menuitem item) return MenuChoice(item); //MainActivity.java: import android.content.intent; import android.net.uri; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; public class MainActivity extends AppCompatActivity protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public boolean oncreateoptionsmenu(menu menu) MenuInflater obj = getmenuinflater(); obj.inflate(r.menu.menu, menu); return super.oncreateoptionsmenu(menu); public boolean onoptionsitemselected(menuitem item) return menuchoice(item);

15 private boolean menuchoice(menuitem item) switch(item.getitemid()) case R.id.Menu1: Intent obj = new Intent(Intent.ACTION_VIEW); obj.setdata(uri.parse("content://contacts/people/1")); startactivity(obj); case R.id.Menu2: Intent obj1 = new Intent(Intent.ACTION_EDIT); obj1.setdata(uri.parse("content://contacts/people/1")); startactivity(obj1); case R.id.Menu3: Intent obj2 = new Intent(Intent.ACTION_DIAL); obj2.setdata(uri.parse("tel: ")); startactivity(obj2); case R.id.Menu4: Intent obj3 = new Intent(Intent.ACTION_VIEW); obj3.setdata(uri.parse("content://contacts/people/")); startactivity(obj3); //activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ibmsap.test_menuxml.mainactivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello World!" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout>

16 //menu.xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:app=" xmlns:android=" <item android:title="main Menu 1"> <menu android:title="sub Menu1"> <item android:title="view A Contact"/> <item android:id="@+id/menu2" android:title="edit A Contact"/> </menu> </item> <item android:id="@+id/mainmenu2" android:title="main Menu 2"> <menu android:title="sub Menu2"> <item android:id="@+id/menu3" android:title="dial A Contact"/> <item android:id="@+id/menu4" android:title="view All Contacts"/> </menu> </item> </menu>

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop Workshop 1. Create an Option Menu, and convert it into Action Bar (Page 1 8) Create an simple Option Menu Convert Option Menu into Action Bar Create Event Listener for Menu and Action Bar Add System Icon

More information

Meniu. Create a project:

Meniu. Create a project: Meniu Create a project: Project name: P0131_MenuSimple Build Target: Android 2.3.3 Application name: MenuSimple Package name: ru.startandroid.develop.menusimple Create Activity: MainActivity Open MainActivity.java.

More information

ANDROID PROGRAMS DAY 3

ANDROID PROGRAMS DAY 3 ANDROID PROGRAMS DAY 3 //Android project to navigate from first page to second page using Intent Step 1: Create a new project Step 2: Enter necessary details while creating project. Step 3: Drag and drop

More information

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

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified

More information

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android. Q.1 Explain the dialog and also explain the Demonstrate working dialog in android. - A dialog is a small window that prompts the user to make a decision or enter additional information. - A dialog does

More information

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

Create Parent Activity and pass its information to Child Activity using Intents. Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;

More information

Intents. Your first app assignment

Intents. Your first app assignment Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work

More information

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

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator. Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are

More information

05. RecyclerView and Styles

05. RecyclerView and Styles 05. RecyclerView and Styles 08.03.2018 1 Agenda Intents Creating Lists with RecyclerView Creating Cards with CardView Application Bar Menu Styles and Themes 2 Intents 3 What is Intent? An Intent is an

More information

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

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2 Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control

More information

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

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation 1. Location Services 1.1 GPS Location 1. Create the Android application with the following attributes. Application Name: MyLocation Project Name: Package Name: MyLocation com.example.mylocation 2. Put

More information

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

Mobila applikationer och trådlösa nät, HI1033, HT2013 Mobila applikationer och trådlösa nät, HI1033, HT2013 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

Our First Android Application

Our First Android Application Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,

More information

1. Simple List. 1.1 Simple List using simple_list_item_1

1. Simple List. 1.1 Simple List using simple_list_item_1 1. Simple List 1.1 Simple List using simple_list_item_1 1. Create the Android application with the following attributes. Application Name: MySimpleList Project Name: Package Name: MySimpleList com.example.mysimplelist

More information

Basic GUI elements - exercises

Basic GUI elements - exercises Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add

More information

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

<uses-permission android:name=android.permission.internet/> Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs 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,

More information

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

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 3 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MainActivity.java File package com.example.tutorialspoint; import android.manifest;

More information

Android Using Menus. Victor Matos Cleveland State University

Android Using Menus. Victor Matos Cleveland State University Lesson 8 Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers http://developer.android.com/index.html

More information

Android Application Development. By : Shibaji Debnath

Android Application Development. By : Shibaji Debnath Android Application Development By : Shibaji Debnath About Me I have over 10 years experience in IT Industry. I have started my career as Java Software Developer. I worked in various multinational company.

More information

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

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 Submitted to: Sir Waqas Asghar MAY 23, 2017 SUBMITTED BY: REHAN ASGHAR Intent in Android What are Intent? An Intent is a messaging object you can use to request

More information

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

Fragment Example Create the following files and test the application on emulator or device. Fragment Example Create the following files and test the application on emulator or device. File: AndroidManifest.xml

More information

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

Tabel mysql. Kode di PHP. Config.php. Service.php Tabel mysql Kode di PHP Config.php Service.php Layout Kode di Main Activity package com.example.mini.webandroid; import android.app.progressdialog; import android.os.asynctask; import android.support.v7.app.appcompatactivity;

More information

Dynamically Create Admob Banner and Interstitial Ads

Dynamically Create Admob Banner and Interstitial Ads Dynamically Create Admob Banner and Interstitial Ads activity_main.xml file 0 0 0

More information

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

Vienos veiklos būsena. Theory

Vienos veiklos būsena. Theory Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is

More information

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

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based

More information

Android Using Menus. Victor Matos Cleveland State University

Android Using Menus. Victor Matos Cleveland State University 8 Android Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers http://developer.android.com/index.html

More information

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

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed. Action Bar Introduction The Action Bar is a widget that is shown on top of the screen. It includes the application logo on its left side together with items available from the options menu on the right.

More information

Data Persistence. Chapter 10

Data Persistence. Chapter 10 Chapter 10 Data Persistence When applications create or capture data from user inputs, those data will only be available during the lifetime of the application. You only have access to that data as long

More information

Mobile and Ubiquitous Computing: Android Programming (part 3)

Mobile and Ubiquitous Computing: Android Programming (part 3) Mobile and Ubiquitous Computing: Android Programming (part 3) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Based on Programming Handheld Systems, Adam Porter, University

More information

Lampiran Program : Res - Layout Activity_main.xml

More information

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

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control. A TextView displays text to the user. TextView Attributes TextView Control android:id - This is the ID which uniquely identifies the control. android:capitalize - If set, specifies that this TextView has

More information

@Bind(R.id.input_ ) EditText EditText Button _loginbutton;

@Bind(R.id.input_ ) EditText EditText Button _loginbutton; package cyborg.pantaucctv; import android.app.progressdialog; import android.content.intent; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.util.log; import android.view.view;

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should

More information

Workshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking

Workshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking Workshop 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking 2. Create Intent with Parsing Data (Page 3 8) Making Phone Call and Dial Access Web Content Playing YouTube Video 3. Create

More information

Statistics http://www.statista.com/topics/840/smartphones/ http://www.statista.com/topics/876/android/ http://www.statista.com/statistics/271774/share-of-android-platforms-on-mobile-devices-with-android-os/

More information

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

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

More information

M.A.D Assignment # 1

M.A.D Assignment # 1 Submitted by: Rehan Asghar Roll no: BSSE (7) 15126 M.A.D Assignment # 1 Submitted to: Sir Waqas Asghar Submitted by: M. Rehan Asghar 4/25/17 Roll no: BSSE 7 15126 XML Code: Calculator Android App

More information

Mobile Software Development for Android - I397

Mobile Software Development for Android - I397 1 Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, 2015-2016 EMAIL: AKAVER@ITCOLLEGE.EE WEB: HTTP://ENOS.ITCOLLEGE.EE/~AKAVER/2015-2016/DISTANCE/ANDROID SKYPE: AKAVER Timetable

More information

android-espresso #androidespresso

android-espresso #androidespresso android-espresso #androidespresso Table of Contents About 1 Chapter 1: Getting started with android-espresso 2 Remarks 2 Examples 2 Espresso setup instructions 2 Checking an Options Menu items (using Spoon

More information

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

Mobila applikationer och trådlösa nät, HI1033, HT2012 Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

Introducing the Android Menu System

Introducing the Android Menu System Introducing the Android Menu System If you ve ever tried to navigate a mobile phone menu system using a stylus or trackball, you ll know that traditional menu systems are awkward to use on mobile devices.

More information

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed

More information

Android HelloWorld - Example. Tushar B. Kute,

Android HelloWorld - Example. Tushar B. Kute, Android HelloWorld - Example Tushar B. Kute, http://tusharkute.com Anatomy of Android Application Anatomy of Android Application Java This contains the.java source files for your project. By default, it

More information

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases.

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases. Managing Data This week, we'll be looking at managing information. There are actually many ways to store information for later retrieval. In fact, feel free to take a look at the Android Developer pages:

More information

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html

More information

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

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { }

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { } Android ActionBar import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { Layout, activity.xml

More information

Fragments. Lecture 11

Fragments. Lecture 11 Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait

More information

Preferences. Marco Ronchetti Università degli Studi di Trento

Preferences. Marco Ronchetti Università degli Studi di Trento 1 Preferences Marco Ronchetti Università degli Studi di Trento SharedPreferences SharedPreferences allows to save and retrieve persistent key-value pairs of primitive data types. This data will persist

More information

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

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Shared Preferences 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran Tanveer, ITU Experts

More information

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

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

More information

Mobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences

Mobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences Agenda Dialogs Menus SharedPreferences Android Application Components 1. Activity 2. Broadcast Receiver 3. Content Provider 4. Service

More information

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

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Android - Widgets Tutorial

Android - Widgets Tutorial Android - Widgets Tutorial A widget is a small gadget or control of your android application placed on the home screen. Widgets can be very handy as they allow you to put your favourite applications on

More information

Android/Java Lightning Tutorial JULY 30, 2018

Android/Java Lightning Tutorial JULY 30, 2018 Android/Java Lightning Tutorial JULY 30, 2018 Java Android uses java as primary language Resource : https://github.mit.edu/6178-2017/lec1 Online Tutorial : https://docs.oracle.com/javase/tutorial/java/nutsandbolts/inde

More information

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

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

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

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application

More information

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

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities

More information

EMBEDDED SYSTEMS PROGRAMMING Android Services

EMBEDDED SYSTEMS PROGRAMMING Android Services EMBEDDED SYSTEMS PROGRAMMING 2016-17 Android Services APP COMPONENTS Activity: a single screen with a user interface Broadcast receiver: responds to system-wide broadcast events. No user interface Service:

More information

Action Bar. Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps.

Action Bar. Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps. 1 Action Bar Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps. 1) App Icon 3) Action Buttons 2)View Control 4) Action Overflows

More information

APPENDIX CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE

APPENDIX CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE APPENDIX FILE MainActivity.java CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE package com.ste.sembakoapp; import Android.content.Intent; import Android.support.v7.app.AppCompatActivity; import Android.os.Bundle;

More information

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

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices. Group B: Assignment No 8 Regularity (2) Performance(5) Oral(3) Total (10) Dated Sign Title of Assignment: To verify the operating system name and version of Mobile devices. Problem Definition: Write a

More information

API Guide for Gesture Recognition Engine. Version 2.0

API Guide for Gesture Recognition Engine. Version 2.0 API Guide for Gesture Recognition Engine Version 2.0 Table of Contents Gesture Recognition API... 3 API URI... 3 Communication Protocol... 3 Getting Started... 4 Protobuf... 4 WebSocket Library... 4 Project

More information

Database Development In Android Applications

Database Development In Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran

More information

... 1... 2... 2... 3... 3... 4... 4... 5... 5... 6... 6... 7... 8... 9... 10... 13... 14... 17 1 2 3 4 file.txt.exe file.txt file.jpg.exe file.mp3.exe 5 6 0x00 0xFF try { in.skip(9058); catch (IOException

More information

Android Apps Development for Mobile Game Lesson 5

Android Apps Development for Mobile Game Lesson 5 Workshop 1. Create a simple Environment Sensors (Page 1 6) Pressure Sensor Ambient Temperature Sensor Light Sensor Relative Humidity Sensor 2. Create a simple Position Sensors (Page 7 8) Proximity Sensor

More information

Android - JSON Parser Tutorial

Android - JSON Parser Tutorial Android - JSON Parser Tutorial JSON stands for JavaScript Object Notation.It is an independent data exchange format and is the best alternative for XML. This chapter explains how to parse the JSON file

More information

Android Application Model I

Android Application Model I Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);

More information

POCKET STUDY. Divyam Kumar Mishra, Mrinmoy Kumar Das Saurav Singh, Prince Kumar

POCKET STUDY. Divyam Kumar Mishra, Mrinmoy Kumar Das Saurav Singh, Prince Kumar POCKET STUDY Divyam Kumar Mishra, Mrinmoy Kumar Das Saurav Singh, Prince Kumar 1 Under Graduate Student, Department of Computer Science and Engineering, SRM University, Chennai, India 2 Under Graduate

More information

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

Software Practice 3 Before we start Today s lecture Today s Task Team organization 1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu India Summer 2012 Review Session Android and Web Working with Views Working with Views Create a new Android project. The app name should

More information

1. Explain the architecture of an Android OS. 10M The following diagram shows the architecture of an Android OS.

1. Explain the architecture of an Android OS. 10M The following diagram shows the architecture of an Android OS. 1. Explain the architecture of an Android OS. 10M The following diagram shows the architecture of an Android OS. Android OS architecture is divided into 4 layers : Linux Kernel layer: 1. Linux Kernel layer

More information

ELET4133: Embedded Systems. Topic 15 Sensors

ELET4133: Embedded Systems. Topic 15 Sensors ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects

More information

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27 Android Coding Dr. J.P.E. Hodgson August 23, 2010 Dr. J.P.E. Hodgson () Android Coding August 23, 2010 1 / 27 Outline Starting a Project 1 Starting a Project 2 Making Buttons Dr. J.P.E. Hodgson () Android

More information

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

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics ArrayAdapter Preferences Widgets Jonathan Diehl, Hendrik Thüs 2 ArrayAdapter Jonathan Diehl, Hendrik Thüs

More information

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

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners Layouts and Views http://developer.android.com/guide/topics/ui/declaring-layout.html http://developer.android.com/reference/android/view/view.html Repo: https://github.com/karlmorris/viewsandlayouts Overview

More information

API Guide for Gesture Recognition Engine. Version 1.1

API Guide for Gesture Recognition Engine. Version 1.1 API Guide for Gesture Recognition Engine Version 1.1 Table of Contents Table of Contents... 2 Gesture Recognition API... 3 API URI... 3 Communication Protocol... 3 Getting Started... 4 Protobuf... 4 WebSocket

More information

Mobile Application Development MyRent Settings

Mobile Application Development MyRent Settings Mobile Application Development MyRent Settings Waterford Institute of Technology October 13, 2016 John Fitzgerald Waterford Institute of Technology, Mobile Application Development MyRent Settings 1/19

More information

Android Workshop: Model View Controller ( MVC):

Android Workshop: Model View Controller ( MVC): Android Workshop: Android Details: Android is framework that provides java programmers the ability to control different aspects of smart devices. This interaction happens through the Android SDK (Software

More information

Have a development environment in 256 or 255 Be familiar with the application lifecycle

Have a development environment in 256 or 255 Be familiar with the application lifecycle Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in

More information

5Displaying Pictures and Menus with Views

5Displaying Pictures and Menus with Views 5Displaying Pictures and Menus with Views WHAT YOU WILL LEARN IN THIS CHAPTER How to use the Gallery, ImageSwitcher, GridView, and ImageView views to display images How to display options menus and context

More information

Programmation Mobile Android Master CCI

Programmation Mobile Android Master CCI Programmation Mobile Android Master CCI Bertrand Estellon Aix-Marseille Université March 23, 2015 Bertrand Estellon (AMU) Android Master CCI March 23, 2015 1 / 266 Navigation entre applications Nous allons

More information

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

android:orientation=horizontal android:layout_margintop=30dp> <Button android:text=button2 Parametrų keitimas veikiančioje aplikacijoje Let s create a project: Project name: P0181_DynamicLayout3 Build Target: Android 2.3.3 Application name: DynamicLayout3 Package name: ru.startandroid.develop.dynamiclayout3

More information

Android Tutorial: Part 3

Android Tutorial: Part 3 Android Tutorial: Part 3 Adding Client TCP/IP software to the Rapid Prototype GUI Project 5.2 1 Step 1: Copying the TCP/IP Client Source Code Quit Android Studio Copy the entire Android Studio project

More information

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

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics Chapter 10 Speech Recognition 10.1 Introduction Speech recognition (SR) by machine, which translates spoken words into text has been a goal of research for more than six decades. It is also known as automatic

More information

Building MyFirstApp Android Application Step by Step. Sang Shin Learn with Passion!

Building MyFirstApp Android Application Step by Step. Sang Shin   Learn with Passion! Building MyFirstApp Android Application Step by Step. Sang Shin www.javapassion.com Learn with Passion! 1 Disclaimer Portions of this presentation are modifications based on work created and shared by

More information

Tutorial: Setup for Android Development

Tutorial: Setup for Android Development Tutorial: Setup for Android Development Adam C. Champion CSE 5236: Mobile Application Development Spring 2018 Based on material from C. Horstmann [1], J. Bloch [2], C. Collins et al. [4], M.L. Sichitiu

More information

COMP61242: Task /04/18

COMP61242: Task /04/18 COMP61242: Task 2 1 16/04/18 1. Introduction University of Manchester School of Computer Science COMP61242: Mobile Communications Semester 2: 2017-18 Laboratory Task 2 Messaging with Android Smartphones

More information

Android CardView Tutorial

Android CardView Tutorial Android CardView Tutorial by Kapil - Wednesday, April 13, 2016 http://www.androidtutorialpoint.com/material-design/android-cardview-tutorial/ YouTube Video We have already discussed about RecyclerView

More information

Time Picker trong Android

Time Picker trong Android Time Picker trong Android Time Picker trong Android cho phép bạn lựa chọn thời gian của ngày trong chế độ hoặc 24 h hoặc AM/PM. Thời gian bao gồm các định dạng hour, minute, và clock. Android cung cấp

More information

Android UI Development

Android UI Development Android UI Development Android UI Studio Widget Layout Android UI 1 Building Applications A typical application will include: Activities - MainActivity as your entry point - Possibly other activities (corresponding

More information

Open Lecture Mobile Programming. Intro to Material Design

Open Lecture Mobile Programming. Intro to Material Design Open Lecture Mobile Programming Intro to Material Design Agenda Introduction to Material Design Applying a Material Theme Toolbar/Action Bar Navigation Drawer RecyclerView CardView Support Design Widgets/Tools

More information

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Overview MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Lecture: MVC Model View Controller What is an App? Android Activity Lifecycle Android Debugging Fixing Rotations & Landscape Layouts Localization

More information