Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

What is System Broadcast

System broadcast is also known as Static broadcast. We use this concept in our day to day phone usage.

For example, when we use our phone and when our phone reaches a certain level of battery percentage, like 4%, name suddenly a notification will come that saying 'Battery Low, please plugin the charger', so this is nothing but a type of a system broadcast.

We use intent filters to generate system broadcast. And three things which are important in system broadcast are, ACTION, DATA, CATEGORY.

Action

This is mandatory part of the intent object and is a string naming the action to be performed - or, in the case of broadcast intents, the action that took place and is being reported.

For example when we launch any application, there will be a main activity of that particular application, we can call it as a Welcome screen of application.

 

List of Android Intent Standard Actions

 

Intent

Description

ACTION_MAIN

Start as a main entry point, does not expect to receive data.

ACTION_VIEW

Displays the data to the user.

ACTION_BATTERY_LOW

This broadcast corresponds to thr “Low Battery warning” system dialog.

ACTION_BOOT_COMPLETED

The OS broadcasts it once, after the system has finished booting.

 

Category

The category is an optional part of intent object and it's a string containing additional information about the kind of component that should handle the intent.

 

List of Android Intent Standard Categories

 

Intent

Description

CATEGORY_INFO

Provides information about the package it is in.

CATEGORY_LAUNCHER

Should be displayed in the top-level launcher.

CATEGORY_HOME

This is the home activity, that is the first activity that is displayed when the device boots.

CATEGORY_APP_MARKET

This activity allows the user to browse and download new applications.

 

Data

Adds a data specification to an intent filter. The specification can be just the data type (the MIME type attribute).

Just a URI, or both data type and a URI.

  • The setData() method specifies data only as a URI.
  • setType() specifies it only as a MIME
  • setDataAndType() specifies it as both a URI and a MIME
  • The URI is read by getData() and the type by getType().

 

1.

ACTION_VIEW content://contacts/people/1 Display information about the person whose identifier is “1”.

2.

ACTION_DIAL content://contacts/people/1 Display the phone dialer with the person filled in.

3.

ACTION_VIEW tel:123 Display the phone dialer with the given number filled in.

 

System Broadcasts

 

Event

Description

Intent.ACTION_BOOT_COMPLETED

Boot completed.

Intent.ACTION_BATTERY_LOW

Triggered on low battery. Typically used to reduce activities in your app which consume power.

Intent.ACTION_POWER_CONNECTED

Power got connected to the device.

Intent.ACTION_POWER_DISCONNECTED

Power got disconnected to the device.

 

This all readymade events are added to System broadcast because they are not dynamically generated by user, according to device's performance they should be generated automatically.

  • For this you can register a receiver for the

android.intent.action.BOOT_COMPLETED system event.

  • This requires the

android.permission.RECEIVE_BOOT_COMPLETED permission.

 

public class MyReceiver extends Broadcast Receiver.

{

                @Override

                public void onReceive(Context context, Intent intent)

                {

                                Toast.makeText(context,”Intent Detected.”,

Toast.LENGTH_LONG).show();

                }

}

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere