Lecture 14. Android Application Development

Similar documents
Android Notification

Notification mechanism

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Programming with Android: Notifications, Threads, Services. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Basic GUI elements - exercises

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Intents. Your first app assignment

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

Practical 1.ListView example

Arrays of Buttons. Inside Android

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

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

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

Embedded Systems Programming - PA8001

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

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

Chapter 5 Flashing Neon FrameLayout

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

Topics of Discussion

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

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

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches


Basic UI elements: Defining Activity UI in the code. Marco Ronchetti Università degli Studi di Trento


Creating a Custom ListView

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

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

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

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

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

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

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

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

Database Development In Android Applications

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

Our First Android Application

South Africa Version Control.

Mobile Computing Fragments

Graphical User Interfaces

Adapter.

Vienos veiklos būsena. Theory

else if(rb2.ischecked()) {

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

Android HelloWorld - Example. Tushar B. Kute,

BSCS 514- Computer Graphics. Course Supervisor : Dr. Humera Tariq Hands on Lab Sessions: Mr. Faraz Naqvi

05. RecyclerView and Styles

Fragments. Lecture 11

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

Android. Broadcasts Services Notifications

Android Workshop: Model View Controller ( MVC):

Android Programs Day 5

Solving an Android Threading Problem

Meniu. Create a project:

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

Android UI Development

ANDROID USER INTERFACE

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

THE CATHOLIC UNIVERSITY OF EASTERN AFRICA A. M. E. C. E. A

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

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

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

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE)

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

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

Text Properties Data Validation Styles/Themes Material Design

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

ANDROID PROGRAMS DAY 3

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

Starting Another Activity Preferences

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

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

ELET4133: Embedded Systems. Topic 15 Sensors

Android Beginners Workshop

Manifest.xml. Activity.java

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

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

android-espresso #androidespresso

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

User Interface Development in Android Applications

Learn about Android Content Providers and SQLite

Simple Currency Converter

INTRODUCTION TO ANDROID

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.

Programmation Mobile Android Master CCI

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

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

Fragments. Lecture 10

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

Tłumaczenie i adaptacja materiałów: dr Tomasz Xięski. Na podstawie prezentacji udostępnionych przez Victor Matos, Cleveland State University.

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

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

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26

android:layout_margintop="5dp" > <EditText android:layout_width="210dp"

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

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

Produced by. Mobile Application Development. Eamonn de Leastar

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

Transcription:

Lecture 14 Android Application Development Notification Instructor Muhammad Owais muhammad.owais@riphah.edu.pk Cell: 03215500223

Notifications Used to notify user for events Three general forms of Notifications Toast Dialogs Status Bar Notifications

Toast Notifications Transitory messages that popup on the current window Automatically fade in & out of view No user interaction or response

Standard Toast Notifications Context context = getapplicationcontext(); CharSequence text = Message to Display"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show();

Custom Toast Notifications <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toast_layout_root" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:background="#7777" > <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginright="10dp" android:src="@drawable/fire_eye_alien" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textcolor="#fff" android:text="i'm Watching You!" /> </LinearLayout>

Custom Toast Notifications public class NotificationToastActivity extends Activity { @Override public void oncreate(bundle savedinstancestate) { LayoutInflater inflater = getlayoutinflater(); View layout = inflater.inflate(r.layout.custom_toast, (ViewGroup)findViewById( R.id.toast_layout_root)); Toast toast = new Toast(getApplicationContext()); toast.setgravity(gravity.center_vertical, 0, 0); toast.setduration(toast.length_long); toast.setview(layout); toast.show(); }

Custom Toast Notifications Example

Status Bar Notifications

Notification Manager System service that manages Notifications e.g., notify & cancel

Adding Light Notification To use the user's default lighting notification.defaults = Notification.DEFAULT_LIGHTS; To use a different lighting notification.ledargb = 0xff00ff00; notification.ledonms = 300; notification.flags = Notification.FLAG_SHOW_LIGHTS;

Adding Sound and Vibration Notification To use the user's default sound notification.defaults = Notification.DEFAULT_SOUND; To use a different sound notification.sound = Uri.parse("file:///sdcard/media/audio/notifications/roo ster_2.mp3"); To use the user's default vibration pattern notification.defaults = Notification.DEFAULT_VIBRATE; To use a different vibration pattern long[] vibrate = { 0, 100, 200, 300 }; notification.vibrate = vibrate;

Remote View <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toast_layout_root" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#7777" android:padding="3dp" > <ImageView android:id="@+id/image" android:layout_width="44dp" android:layout_height="44dp" android:layout_marginright="10dp" android:contentdescription="pic" android:src="@drawable/notification" /> <TextView android:id="@+id/text" android:layout_width="match_parent" android:layout_height="wrap_content" android:textcolor="#fff" android:textsize="24sp" /> </LinearLayout>

Creating Notifications public class MainActivity extends Activity { // Notification ID to allow for future updates private static final int MY_NOTIFICATION_ID = 1; // Notification count private int mnotificationcount; // Notification Text Elements private final CharSequence tickertext = "This is Really, Really, Super Long Notification Message"; private final CharSequence contenttitle = "Notification"; private final CharSequence contenttext = "You've Been Notified"; // Notification Action Elements private Intent mnotificationintent; private PendingIntent mcontentintent; // Notification Sound and Vibration on Arrival private Uri sounduri = Uri.parse("android.resource:// com.samd.notificationstatusbar/" + R.raw.alarm_rooster); private long[] mvibratepattern = {0,200,200,300}; RemoteViews mcontentviews = new RemoteViews( "com.samd.notificationstatusbar", R.layout.notificationview);

Creating Notifications protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mnotificationintent = new Intent(getApplicationContext(), NotificationActivity.class ); mcontentintent = PendingIntent.getActivity( getapplicationcontext(), 0, mnotificationintent, Intent.FLAG_ACTIVITY_NEW_TASK); final Button btn = (Button)findViewById(R.id.notify); btn.setonclicklistener(new OnClickListener() {

Creating Notifications public void onclick(view arg0) { mcontentviews.settextviewtext(r.id.text, contenttext + "(" + ++mnotificationcount + ")"); // Build the Notification Notification.Builder notificationbuilder = new Notification.Builder(getApplicationContext()).setTicker(tickerText).setSmallIcon(R.drawable.samllnotification).setAutoCancel(true).setContentIntent(mContentIntent).setSound(soundURI).setVibrate(mVibratePattern).setContent(mContentViews); // Pass the Notification to the NotificationManager NotificationManager mnotificationmanager = (NotificationManager) getsystemservice(context.notification_service); mnotificationmanager.notify(my_notification_id, notificationbuilder.build()); } });

Questions?