SlideShare a Scribd company logo
Alarms and
Broadcast Receivers


           Razvan Prejbeanu
           Eduard Dorobanțu
Cuprins

•   AlarmManager
    o Scop
    o Implementare
    o Rezultate obtinute



•   BroadcastReceiver
    o Scop
    o Implementare
    o Rezultate obtinute
Alarm Manager
                       - Scop -


•   Pentru a rula cod la un moment de timp specific,
    fara a-l lega de o activitate a aplicatiei

•   Pentru a programa operatii la intervale de timp

•   Pentru a ne asigura ca o zona de cod se executa
    atomic ( se obtine un wake lock asupra sistemului)
Alarm Manager
                 - Implementare -
•   Clasa AlarmManager - acces la Android
    AlarmService

•   Alarme one-time sau repeating

•   La timpul prestabilit - Intent trimis in sistem (prins
    de BroadcastReceiver, Service sau Activity)

•   4 tipuri de alarme:
    o RTC
- Implementare (2) -

 Obtinerea unei instante:



 One time alarm:
- Implementare (3) -
   Repeating Alarms:
     o   setRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation )




     o   setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent
         operation )




   Oprirea unei alarme repetitive:
Alarm Manager
            - Rezultate obținute -


•   Show notification
•   Start service
•   Start Activity
•   Trigger Broadcast Receiver
Broadcast Receivers
                       - Scop -


•   Extind clasa BroadcastReceiver
•   Recepționeaza si reacționeaza la primirea
    anunțurilor de tip Broadcast
Broadcast Receivers
                      - Implementare -
•   Extindere clasa BroadcastReceiver



•   Inregistrare receiver in AndroidManifest
     o numele clasei
     o intent-filter - acele Intents la care asculta receiver-ul
- Implementare (2) -

•   Se recepționează Broadcast Intents prin metoda onReceive()
    din BroadcastReceiver




•   Se trimit Broadcasts prin sendBroadcast(Intent sourceIntent):
Broadcast Receivers
            - Rezultate obținute -


•   Sunt receptionate diverse stări ale serviciilor
    telefonului:

    o   low battery
    o   power connected
    o   shutdown
    o   receiving phone call
Putting them together

•   Alarm Manager inițiaza Broadcast
    o   sendBroadcast();


•   Broadcast Receiver recepționeaza anunțul
    de tip Broadcast
    o   receiveBroadcast();


•   Broadcast Receiver reacționeaza și rezolva
    acest tip de anunț
Concluzii


•   Folosite pentru creearea unei aplicații ce
    amintește utilizatorului de existența si de
    modificările sale
Documentatie

•   http://www.developer.android.com

•   http://www.vogella.com/articles/AndroidBroadcastRecei
    ver/article.html

•   http://www.androidcompetencycenter.com/2009/02/andr
    oid-basics-alarm-service

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Android Alarms & Broadcast Receivers

  • 1. Alarms and Broadcast Receivers Razvan Prejbeanu Eduard Dorobanțu
  • 2. Cuprins • AlarmManager o Scop o Implementare o Rezultate obtinute • BroadcastReceiver o Scop o Implementare o Rezultate obtinute
  • 3.
  • 4.
  • 5. Alarm Manager - Scop - • Pentru a rula cod la un moment de timp specific, fara a-l lega de o activitate a aplicatiei • Pentru a programa operatii la intervale de timp • Pentru a ne asigura ca o zona de cod se executa atomic ( se obtine un wake lock asupra sistemului)
  • 6. Alarm Manager - Implementare - • Clasa AlarmManager - acces la Android AlarmService • Alarme one-time sau repeating • La timpul prestabilit - Intent trimis in sistem (prins de BroadcastReceiver, Service sau Activity) • 4 tipuri de alarme: o RTC
  • 7. - Implementare (2) -  Obtinerea unei instante:  One time alarm:
  • 8. - Implementare (3) -  Repeating Alarms: o setRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation ) o setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation )  Oprirea unei alarme repetitive:
  • 9. Alarm Manager - Rezultate obținute - • Show notification • Start service • Start Activity • Trigger Broadcast Receiver
  • 10. Broadcast Receivers - Scop - • Extind clasa BroadcastReceiver • Recepționeaza si reacționeaza la primirea anunțurilor de tip Broadcast
  • 11. Broadcast Receivers - Implementare - • Extindere clasa BroadcastReceiver • Inregistrare receiver in AndroidManifest o numele clasei o intent-filter - acele Intents la care asculta receiver-ul
  • 12. - Implementare (2) - • Se recepționează Broadcast Intents prin metoda onReceive() din BroadcastReceiver • Se trimit Broadcasts prin sendBroadcast(Intent sourceIntent):
  • 13. Broadcast Receivers - Rezultate obținute - • Sunt receptionate diverse stări ale serviciilor telefonului: o low battery o power connected o shutdown o receiving phone call
  • 14. Putting them together • Alarm Manager inițiaza Broadcast o sendBroadcast(); • Broadcast Receiver recepționeaza anunțul de tip Broadcast o receiveBroadcast(); • Broadcast Receiver reacționeaza și rezolva acest tip de anunț
  • 15. Concluzii • Folosite pentru creearea unei aplicații ce amintește utilizatorului de existența si de modificările sale
  • 16. Documentatie • http://www.developer.android.com • http://www.vogella.com/articles/AndroidBroadcastRecei ver/article.html • http://www.androidcompetencycenter.com/2009/02/andr oid-basics-alarm-service