SlideShare a Scribd company logo
Alarm
Alarm
● Used to schedule time-based operations
● Works even if the app is not running
● Useful for:
○ Notifications
○ Reminders
○ Periodic background tasks
● 🔧 Handled using AlarmManager class
Types of Alarms
Type Description
ELAPSED_REALTIME After boot, does not wake device
ELAPSED_REALTIME_WAKEUP After boot, wakes device if needed
RTC Specific clock time, does not wake device
RTC_WAKEUP Clock time + wakes device if sleeping
Setting a One-Time Alarm
Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent,
PendingIntent.FLAG_IMMUTABLE);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
long triggerAt = System.currentTimeMillis() + 10000; // 10 sec later
am.set(AlarmManager.RTC_WAKEUP, triggerAt, pi);
AlarmReceiver (BroadcastReceiver)
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Alarm Triggered!",
Toast.LENGTH_SHORT).show();
}
}
📌 Register in AndroidManifest.xml
<receiver android:name=".AlarmReceiver" />
Networking
Networking in Android
It refers to the process of sending or receiving data over the internet using APIs,
services, or protocols (like HTTP or HTTPS).
It allows Android apps to fetch data from web servers or cloud APIs.
🔧 Common Use Cases:
● Accessing RESTful APIs (e.g., weather, news)
● Uploading/downloading files
● Sending form data to a server
● Performing authentication and login
🔗 Popular Networking Tools & APIs
Tool/API Description
HttpURLConnection Basic Java HTTP request/response handling
Retrofit Type-safe, high-level HTTP client (most popular)
Volley Google library for fast network operations
OkHttp Powerful and customizable HTTP client
Process to make network call
1. Permissions Required (in AndroidManifest.xml)
<uses-permission android:name="android.permission.INTERNET"/>
If using Wi-Fi or mobile data status
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
Process to make network call
2. Example using Retrofit ( can be anything like Volley , OkHttp)
a. Add dependency
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
b. Define API Interface
public interface ApiService {
@GET("posts/1")
Call<Post> getPost();
}
Process to make network call
c. Use in Activity
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("MYAPI_URL")
.addConverterFactory(GsonConverterFactory.create())
.build();
Process to make network call
c, continues…
ApiService api = retrofit.create(ApiService.class);
api.getPost().enqueue(new Callback<Post>() {
@Override
public void onResponse(Call<Post> call, Response<Post> response) { //
Handle successful response }
@Override
public void onFailure(Call<Post> call, Throwable t) {// Handle error}
});
Graphics
Graphics in Android
● Graphics refer to drawing visual content on the screen.
● Used for:
○ Custom UI
○ Game development
○ Image editing apps
○ Supports 2D and 3D rendering
Categories of Graphics
Category Description
2D Graphics Drawing lines, shapes, text, bitmaps
3D Graphics Advanced rendering using OpenGL ES
Drawable XML-based visual elements (shapes, colors)
Techniques for Graphics
1. Canvas
● Canvas class is used to draw 2D graphics on View
● Drawing operations:
○ drawLine(), drawRect(), drawCircle(), drawText()
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.RED);
canvas.drawCircle(100, 100, 50, paint);
}
Techniques for Graphics
2. Drawable Resources
● Use XML to define shapes and colors
● Types: Shape, Bitmap, Layer-list, Selector
<shape android:shape="rectangle">
<solid android:color="#00FF00"/>
</shape>
Techniques for Graphics
3. OpenGL ES
● For 3D graphics and advanced rendering
● Uses
○ GLSurfaceView – Surface to render graphics
○ GLSurfaceView.Renderer – Custom renderer implementation
○ Shaders (ES 2.0+) – Used to draw complex graphics
● Ideal for games, visual simulations, and AR
Animation
Animation in Android
● Animation is the visual transition of objects or UI elements over time
● Makes UI more dynamic, engaging, and interactive
● Android supports various animation systems:
○ View Animation
○ Property Animation
○ Drawable Animation
View Animation (Tween Animation)
● Animates views by changing.
○ Position (translate)
○ Size (scale)
○ Rotation (rotate)
○ Transparency (alpha)
● Defined in XML or Java
Animation anim =
AnimationUtils.loadAnimation(this,
R.anim.translate);
myView.startAnimation(anim);
<translate
android:fromXDelta="0%"
android:toXDelta="100%"
android:duration="1000" />
Property Animation
● Introduced in API 11+
● Animates any property of any object (not just views)
● More powerful and flexible than View Animation
ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
anim.setDuration(1000);
anim.start();
Drawable Animation (Frame Animation)
● Animation using a series of images shown one after another
● Works like a flipbook
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/frame1" android:duration="50" />
<item android:drawable="@drawable/frame2" android:duration="50" />
</animation-list>
ImageView img = findViewById(R.id.imageView);
img.setBackgroundResource(R.drawable.frame_animation);
AnimationDrawable anim = (AnimationDrawable) img.getBackground();
anim.start();

More Related Content

PDF
Android development - the basics, MFF UK, 2013
PPTX
Android Applications Development: A Quick Start Guide
PPTX
Android Lollipop: The developer's perspective
PDF
Android 3.0 Portland Java User Group 2011-03-15
PDF
What's new in Android Lollipop
PDF
Android development - the basics, MFF UK, 2012
PDF
Android Jumpstart Jfokus
PDF
Android development first steps
Android development - the basics, MFF UK, 2013
Android Applications Development: A Quick Start Guide
Android Lollipop: The developer's perspective
Android 3.0 Portland Java User Group 2011-03-15
What's new in Android Lollipop
Android development - the basics, MFF UK, 2012
Android Jumpstart Jfokus
Android development first steps

Similar to Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf (20)

PPTX
Android Basic Concept
PPTX
Introduction to android basics
PDF
Android 3.1 - Portland Code Camp 2011
PDF
Android - Open Source Bridge 2011
PDF
Android_Architectuture pdf complete detail
PDF
What's new in Android O
PPT
Beginning Native Android Apps
PPTX
Android application development fundamentals
PPTX
Android101 - Intro and Basics
PPTX
Android 3
PPTX
Android Architecture v2 presetnation extension
PPTX
Dori waldman android _course_2
PDF
Android development - the basics, MFF UK, 2014
PPTX
W2_Lec03_Lec_04_Activity.pptx
PDF
INTRODUCTION TO FORMS OF SERVICES AND ITS LIFE CYCLE
PPTX
Dori waldman android _course
PPTX
Intro to Mobile app development Android.pptx
PDF
Android 5.0 internals and inferiority complex droidcon.de 2015
PPTX
From JavaEE to Android: Way in one click?
PDF
Inside Android's UI at AnDevCon V
Android Basic Concept
Introduction to android basics
Android 3.1 - Portland Code Camp 2011
Android - Open Source Bridge 2011
Android_Architectuture pdf complete detail
What's new in Android O
Beginning Native Android Apps
Android application development fundamentals
Android101 - Intro and Basics
Android 3
Android Architecture v2 presetnation extension
Dori waldman android _course_2
Android development - the basics, MFF UK, 2014
W2_Lec03_Lec_04_Activity.pptx
INTRODUCTION TO FORMS OF SERVICES AND ITS LIFE CYCLE
Dori waldman android _course
Intro to Mobile app development Android.pptx
Android 5.0 internals and inferiority complex droidcon.de 2015
From JavaEE to Android: Way in one click?
Inside Android's UI at AnDevCon V
Ad

More from Nabin Dhakal (15)

PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
PPTX
Broadcast receiver- How Android apps listen to system-wide or app-specific ev...
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
PPTX
Menu in Android (Define,Create,Inflate and Click Handler)
PPTX
Unit Two - Java Architecture and OOPS
PPTX
Chapter One - Introduction to Mobile Oses
PPTX
Unit 1 -Programming Languages(Programming Logic and Techniques)
PPTX
UNIT 3- Programming Technique(Programming Logic and Technique)
PPTX
UNIT 5- Standalone and Client Server Programming Concept
PPTX
UNIT 4- Program Maintenance(Programming Logic & Techniques)
PPTX
Unit 2 -Software-Development (Programming Logic and Techniques)
PPTX
ListView.pptx
PPTX
SQLite in Flutter.pptx
PPTX
Hive in Flutter.pptx
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Broadcast receiver- How Android apps listen to system-wide or app-specific ev...
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Menu in Android (Define,Create,Inflate and Click Handler)
Unit Two - Java Architecture and OOPS
Chapter One - Introduction to Mobile Oses
Unit 1 -Programming Languages(Programming Logic and Techniques)
UNIT 3- Programming Technique(Programming Logic and Technique)
UNIT 5- Standalone and Client Server Programming Concept
UNIT 4- Program Maintenance(Programming Logic & Techniques)
Unit 2 -Software-Development (Programming Logic and Techniques)
ListView.pptx
SQLite in Flutter.pptx
Hive in Flutter.pptx
Ad

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
top salesforce developer skills in 2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Transform Your Business with a Software ERP System
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
medical staffing services at VALiNTRY
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
history of c programming in notes for students .pptx
Nekopoi APK 2025 free lastest update
PTS Company Brochure 2025 (1).pdf.......
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
top salesforce developer skills in 2025.pdf
Operating system designcfffgfgggggggvggggggggg
Designing Intelligence for the Shop Floor.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Transform Your Business with a Software ERP System
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
medical staffing services at VALiNTRY
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Navsoft: AI-Powered Business Solutions & Custom Software Development
Design an Analysis of Algorithms I-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 41
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Odoo Companies in India – Driving Business Transformation.pdf
history of c programming in notes for students .pptx

Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf

  • 2. Alarm ● Used to schedule time-based operations ● Works even if the app is not running ● Useful for: ○ Notifications ○ Reminders ○ Periodic background tasks ● 🔧 Handled using AlarmManager class
  • 3. Types of Alarms Type Description ELAPSED_REALTIME After boot, does not wake device ELAPSED_REALTIME_WAKEUP After boot, wakes device if needed RTC Specific clock time, does not wake device RTC_WAKEUP Clock time + wakes device if sleeping
  • 4. Setting a One-Time Alarm Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_IMMUTABLE); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); long triggerAt = System.currentTimeMillis() + 10000; // 10 sec later am.set(AlarmManager.RTC_WAKEUP, triggerAt, pi);
  • 5. AlarmReceiver (BroadcastReceiver) public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, "Alarm Triggered!", Toast.LENGTH_SHORT).show(); } } 📌 Register in AndroidManifest.xml <receiver android:name=".AlarmReceiver" />
  • 7. Networking in Android It refers to the process of sending or receiving data over the internet using APIs, services, or protocols (like HTTP or HTTPS). It allows Android apps to fetch data from web servers or cloud APIs. 🔧 Common Use Cases: ● Accessing RESTful APIs (e.g., weather, news) ● Uploading/downloading files ● Sending form data to a server ● Performing authentication and login
  • 8. 🔗 Popular Networking Tools & APIs Tool/API Description HttpURLConnection Basic Java HTTP request/response handling Retrofit Type-safe, high-level HTTP client (most popular) Volley Google library for fast network operations OkHttp Powerful and customizable HTTP client
  • 9. Process to make network call 1. Permissions Required (in AndroidManifest.xml) <uses-permission android:name="android.permission.INTERNET"/> If using Wi-Fi or mobile data status <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  • 10. Process to make network call 2. Example using Retrofit ( can be anything like Volley , OkHttp) a. Add dependency implementation 'com.squareup.retrofit2:retrofit:2.9.0' b. Define API Interface public interface ApiService { @GET("posts/1") Call<Post> getPost(); }
  • 11. Process to make network call c. Use in Activity Retrofit retrofit = new Retrofit.Builder() .baseUrl("MYAPI_URL") .addConverterFactory(GsonConverterFactory.create()) .build();
  • 12. Process to make network call c, continues… ApiService api = retrofit.create(ApiService.class); api.getPost().enqueue(new Callback<Post>() { @Override public void onResponse(Call<Post> call, Response<Post> response) { // Handle successful response } @Override public void onFailure(Call<Post> call, Throwable t) {// Handle error} });
  • 14. Graphics in Android ● Graphics refer to drawing visual content on the screen. ● Used for: ○ Custom UI ○ Game development ○ Image editing apps ○ Supports 2D and 3D rendering
  • 15. Categories of Graphics Category Description 2D Graphics Drawing lines, shapes, text, bitmaps 3D Graphics Advanced rendering using OpenGL ES Drawable XML-based visual elements (shapes, colors)
  • 16. Techniques for Graphics 1. Canvas ● Canvas class is used to draw 2D graphics on View ● Drawing operations: ○ drawLine(), drawRect(), drawCircle(), drawText() @Override protected void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setColor(Color.RED); canvas.drawCircle(100, 100, 50, paint); }
  • 17. Techniques for Graphics 2. Drawable Resources ● Use XML to define shapes and colors ● Types: Shape, Bitmap, Layer-list, Selector <shape android:shape="rectangle"> <solid android:color="#00FF00"/> </shape>
  • 18. Techniques for Graphics 3. OpenGL ES ● For 3D graphics and advanced rendering ● Uses ○ GLSurfaceView – Surface to render graphics ○ GLSurfaceView.Renderer – Custom renderer implementation ○ Shaders (ES 2.0+) – Used to draw complex graphics ● Ideal for games, visual simulations, and AR
  • 20. Animation in Android ● Animation is the visual transition of objects or UI elements over time ● Makes UI more dynamic, engaging, and interactive ● Android supports various animation systems: ○ View Animation ○ Property Animation ○ Drawable Animation
  • 21. View Animation (Tween Animation) ● Animates views by changing. ○ Position (translate) ○ Size (scale) ○ Rotation (rotate) ○ Transparency (alpha) ● Defined in XML or Java Animation anim = AnimationUtils.loadAnimation(this, R.anim.translate); myView.startAnimation(anim); <translate android:fromXDelta="0%" android:toXDelta="100%" android:duration="1000" />
  • 22. Property Animation ● Introduced in API 11+ ● Animates any property of any object (not just views) ● More powerful and flexible than View Animation ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); anim.setDuration(1000); anim.start();
  • 23. Drawable Animation (Frame Animation) ● Animation using a series of images shown one after another ● Works like a flipbook <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/frame1" android:duration="50" /> <item android:drawable="@drawable/frame2" android:duration="50" /> </animation-list> ImageView img = findViewById(R.id.imageView); img.setBackgroundResource(R.drawable.frame_animation); AnimationDrawable anim = (AnimationDrawable) img.getBackground(); anim.start();