SlideShare a Scribd company logo
1 of 23
Download to read offline
Cloud
InteractionDesign
Android
Toast
Toast
Toast
Context  context  =  getApplicationContext();                 
CharSequence text  =  "Hello  toast!";                
int duration  =  Toast.LENGTH_SHORT;                 
Toast  toast  =  Toast.makeText(context,   text,  duration);                
toast.show();
Notifications
Notifications
Five priority levels:
– PRIORITY_MIN (-2) to PRIORITY_MAX (2);
– if not set, the priority defaults to PRIORITY_DEFAULT (0).
NotificationsPriorities
Notifications
NotificationCompat.Builder mBuilder = new  
NotificationCompat.Builder(this)                                                 
.setSmallIcon(android.R.drawable.stat_notify_more)                                               
.setContentTitle("My   notification")                                                 
.setContentText("Hello   World!");
Notifications
NotificationCompat.Builder mBuilder = new  
NotificationCompat.Builder(this)                                                 
.setSmallIcon(android.R.drawable.stat_notify_more)                                               
.setContentTitle("My   notification")                                                 
.setContentText("Hello   World!");
Threads
UI Thread, AsyncTask, Handler
BroadcastReceiver class
Alarms
Alarms / Scheduling
Google Cloud Messaging (GCM)
with SyncAdapter
Alarms Use Cases
• MMS – Retry Scheduler
• Bluetooth [Discoverable] Timeout
• Notifications
• Syncing data with the server
• ..etc.
Alarms Firing
• ELAPSED_REALTIME
– Fires the pending intent based on the amount of time since the device was booted, but doesn't
wake up the device. The elapsed time includes any time during which the device was asleep.
• ELAPSED_REALTIME_WAKEUP
– Wakes up the device and fires the pending intent after the specified length of time has elapsed
since device boot.
• RTC
– Fires the pending intent at the specified time but does not wake up the device.
• RTC_WAKEUP
– Wakes up the device to fire the pending intent at the specified time.
https://developer.android.com/training/scheduling/alarms.html
ELAPSED_REALTIME_WAKEUP
private  AlarmManager alarmMgr;
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
AlarmManager.INTERVAL_HALF_HOUR,
AlarmManager.INTERVAL_HALF_HOUR,  alarmIntent);
RTC
private  AlarmManager alarmMgr;
//  Set  the  alarm  to  start  at  approximately  2:00  p.m.
Calendar  calendar  =  Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY,  14);
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,  
calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY,
alarmIntent);
Back to
BroadcastReceiver
class
Fire Alarm on Booting Example
BroadcastReceiver on Booting
• Add a permission:
<uses-­‐permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
• Implement a BroadcastReceiver called SampleBootReceiver:
public  class  SampleBootReceiver extends  BroadcastReceiver {
@Override
public  void  onReceive(Context  context,  Intent  intent)  {
if  (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))  {
//  Set  the  alarm  here.
}
}
}
• Set the SampleBootReceiver to fire on Boot:
<receiver  android:name=".SampleBootReceiver"
android:enabled="false">
<intent-­‐filter>
<action  android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-­‐filter>
</receiver>
BroadcastReceiver on Booting
• Add a permission:
<uses-­‐permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
• Implement a BroadcastReceiver called SampleBootReceiver:
public  class  SampleBootReceiver extends  BroadcastReceiver {
@Override
public  void  onReceive(Context  context,  Intent  intent)  {
if  (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))  {
//  Set  the  alarm  here.
}
}
}
• Set the SampleBootReceiver to fire on Boot:
<receiver  android:name=".SampleBootReceiver"
android:enabled="false">
<intent-­‐filter>
<action  android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-­‐filter>
</receiver>
BroadcastReceiver on Booting
• Add a permission:
<uses-­‐permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
• Implement a BroadcastReceiver called SampleBootReceiver:
public  class  SampleBootReceiver extends  BroadcastReceiver {
@Override
public  void  onReceive(Context  context,  Intent  intent)  {
if  (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))  {
//  Set  the  alarm  here.
}
}
}
• Set the SampleBootReceiver to fire on Boot:
<receiver  android:name=".SampleBootReceiver"
android:enabled="false">
<intent-­‐filter>
<action  android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-­‐filter>
</receiver>

More Related Content

Viewers also liked

Android ui dialog
Android ui dialogAndroid ui dialog
Android ui dialogKrazy Koder
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in androidDurai S
 
Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 

Viewers also liked (6)

Android ui dialog
Android ui dialogAndroid ui dialog
Android ui dialog
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in android
 
Android ui menu
Android ui menuAndroid ui menu
Android ui menu
 
Android UI Development
Android UI DevelopmentAndroid UI Development
Android UI Development
 
Android notification
Android notificationAndroid notification
Android notification
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 

Similar to Android L04 - Notifications and Threading

Sierraware ARM hypervisor
Sierraware ARM hypervisor Sierraware ARM hypervisor
Sierraware ARM hypervisor Sierraware
 
Pandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS
 
Study of arduino for irrigation based control using android app
Study of arduino for irrigation based control using android appStudy of arduino for irrigation based control using android app
Study of arduino for irrigation based control using android appIRJET Journal
 
How to Create a Countdown Timer in Python.pdf
How to Create a Countdown Timer in Python.pdfHow to Create a Countdown Timer in Python.pdf
How to Create a Countdown Timer in Python.pdfabhishekdf3
 
Android tutorial (2)
Android tutorial (2)Android tutorial (2)
Android tutorial (2)Kumar
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Weargabrielemariotti
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingPeter R. Egli
 
Manage all the things, small and big, with open source LwM2M implementations ...
Manage all the things, small and big, with open source LwM2M implementations ...Manage all the things, small and big, with open source LwM2M implementations ...
Manage all the things, small and big, with open source LwM2M implementations ...Benjamin Cabé
 
Local Notification Tutorial
Local Notification TutorialLocal Notification Tutorial
Local Notification TutorialKetan Raval
 
Break Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-studyBreak Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-studyUmair Vatao
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementationRajan Kumar
 
Free rtos workshop3@nuu
Free rtos workshop3@nuuFree rtos workshop3@nuu
Free rtos workshop3@nuu紀榮 陳
 
Connecting IBM MessageSight to the Enterprise
Connecting IBM MessageSight to the EnterpriseConnecting IBM MessageSight to the Enterprise
Connecting IBM MessageSight to the EnterpriseAndrew Schofield
 

Similar to Android L04 - Notifications and Threading (20)

The Timer
The TimerThe Timer
The Timer
 
How to build typing indicator in a Chat app
How to build typing indicator in a Chat appHow to build typing indicator in a Chat app
How to build typing indicator in a Chat app
 
6. TinyOS_2.pdf
6. TinyOS_2.pdf6. TinyOS_2.pdf
6. TinyOS_2.pdf
 
Sierraware ARM hypervisor
Sierraware ARM hypervisor Sierraware ARM hypervisor
Sierraware ARM hypervisor
 
Pandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 Agent
 
Manual of the CSS Alarm Handler (Beast)
Manual of the CSS Alarm Handler (Beast)Manual of the CSS Alarm Handler (Beast)
Manual of the CSS Alarm Handler (Beast)
 
Lab 1 new
Lab 1 newLab 1 new
Lab 1 new
 
Study of arduino for irrigation based control using android app
Study of arduino for irrigation based control using android appStudy of arduino for irrigation based control using android app
Study of arduino for irrigation based control using android app
 
How to Create a Countdown Timer in Python.pdf
How to Create a Countdown Timer in Python.pdfHow to Create a Countdown Timer in Python.pdf
How to Create a Countdown Timer in Python.pdf
 
Android tutorial (2)
Android tutorial (2)Android tutorial (2)
Android tutorial (2)
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
GCM aperitivo Android
GCM aperitivo AndroidGCM aperitivo Android
GCM aperitivo Android
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message Queueing
 
Manage all the things, small and big, with open source LwM2M implementations ...
Manage all the things, small and big, with open source LwM2M implementations ...Manage all the things, small and big, with open source LwM2M implementations ...
Manage all the things, small and big, with open source LwM2M implementations ...
 
Local Notification Tutorial
Local Notification TutorialLocal Notification Tutorial
Local Notification Tutorial
 
Break Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-studyBreak Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-study
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
 
Free rtos workshop3@nuu
Free rtos workshop3@nuuFree rtos workshop3@nuu
Free rtos workshop3@nuu
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Connecting IBM MessageSight to the Enterprise
Connecting IBM MessageSight to the EnterpriseConnecting IBM MessageSight to the Enterprise
Connecting IBM MessageSight to the Enterprise
 

More from Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieMohammad Shaker
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to GamesMohammad Shaker
 
Indie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenIndie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenMohammad Shaker
 
Indie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesIndie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesMohammad Shaker
 

More from Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an Indie
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to Games
 
Indie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenIndie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSeven
 
Indie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesIndie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in Games
 

Recently uploaded

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 

Recently uploaded (20)

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 

Android L04 - Notifications and Threading

  • 4. Toast Context  context  =  getApplicationContext();                 CharSequence text  =  "Hello  toast!";                 int duration  =  Toast.LENGTH_SHORT;                 Toast  toast  =  Toast.makeText(context,   text,  duration);                 toast.show();
  • 7. Five priority levels: – PRIORITY_MIN (-2) to PRIORITY_MAX (2); – if not set, the priority defaults to PRIORITY_DEFAULT (0). NotificationsPriorities
  • 8. Notifications NotificationCompat.Builder mBuilder = new   NotificationCompat.Builder(this)                                                 .setSmallIcon(android.R.drawable.stat_notify_more)                                               .setContentTitle("My   notification")                                                 .setContentText("Hello   World!");
  • 9. Notifications NotificationCompat.Builder mBuilder = new   NotificationCompat.Builder(this)                                                 .setSmallIcon(android.R.drawable.stat_notify_more)                                               .setContentTitle("My   notification")                                                 .setContentText("Hello   World!");
  • 14. Google Cloud Messaging (GCM) with SyncAdapter
  • 15. Alarms Use Cases • MMS – Retry Scheduler • Bluetooth [Discoverable] Timeout • Notifications • Syncing data with the server • ..etc.
  • 16. Alarms Firing • ELAPSED_REALTIME – Fires the pending intent based on the amount of time since the device was booted, but doesn't wake up the device. The elapsed time includes any time during which the device was asleep. • ELAPSED_REALTIME_WAKEUP – Wakes up the device and fires the pending intent after the specified length of time has elapsed since device boot. • RTC – Fires the pending intent at the specified time but does not wake up the device. • RTC_WAKEUP – Wakes up the device to fire the pending intent at the specified time. https://developer.android.com/training/scheduling/alarms.html
  • 18. RTC private  AlarmManager alarmMgr; //  Set  the  alarm  to  start  at  approximately  2:00  p.m. Calendar  calendar  =  Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY,  14); alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,   calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, alarmIntent);
  • 20. Fire Alarm on Booting Example
  • 21. BroadcastReceiver on Booting • Add a permission: <uses-­‐permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> • Implement a BroadcastReceiver called SampleBootReceiver: public  class  SampleBootReceiver extends  BroadcastReceiver { @Override public  void  onReceive(Context  context,  Intent  intent)  { if  (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))  { //  Set  the  alarm  here. } } } • Set the SampleBootReceiver to fire on Boot: <receiver  android:name=".SampleBootReceiver" android:enabled="false"> <intent-­‐filter> <action  android:name="android.intent.action.BOOT_COMPLETED"></action> </intent-­‐filter> </receiver>
  • 22. BroadcastReceiver on Booting • Add a permission: <uses-­‐permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> • Implement a BroadcastReceiver called SampleBootReceiver: public  class  SampleBootReceiver extends  BroadcastReceiver { @Override public  void  onReceive(Context  context,  Intent  intent)  { if  (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))  { //  Set  the  alarm  here. } } } • Set the SampleBootReceiver to fire on Boot: <receiver  android:name=".SampleBootReceiver" android:enabled="false"> <intent-­‐filter> <action  android:name="android.intent.action.BOOT_COMPLETED"></action> </intent-­‐filter> </receiver>
  • 23. BroadcastReceiver on Booting • Add a permission: <uses-­‐permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> • Implement a BroadcastReceiver called SampleBootReceiver: public  class  SampleBootReceiver extends  BroadcastReceiver { @Override public  void  onReceive(Context  context,  Intent  intent)  { if  (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))  { //  Set  the  alarm  here. } } } • Set the SampleBootReceiver to fire on Boot: <receiver  android:name=".SampleBootReceiver" android:enabled="false"> <intent-­‐filter> <action  android:name="android.intent.action.BOOT_COMPLETED"></action> </intent-­‐filter> </receiver>