First, IntroductionBroadcast receiver is a broadcast receiver that receives custom and system anchors. It can also be called a listener.Broadcast intent, like intent, is the medium of communication, and unlike intent, broadcast intent is received by multiple components at the same time.Broadcast intent
Dynamic register broadcast receiver and dynamic broadcast ReceiverDynamically register broadcast recipients
This code serves the same purpose as the code below the static register broadcast receiver:
It is used to listen t
Explanation of Intent in Android (2) Introduction to using Intent to Broadcast events and Broadcast Receiver
The first article explains how to use Intent to start new application components. However, they can also use the sendBroadcast method to anonymously broadcast messages between components.
As a system-level messa
In the first article, we've seen how to use intent to launch new application components, but in fact they can also use the Sendbroadcast method to broadcast messages anonymously between components.As a system-level messaging mechanism, intent can send structured messages between processes. Therefore, the broadcast receiver is implemented to monitor and respond to
As the name suggests, braodcast receiver is a broadcast receiver. It is similar to the time processing mechanism, but the event processing mechanism is program component-level (for example, the Click Event of a button ), the broadcast event processing mechanism is system-level. We can use intent to start a component, o
Broadcastreceiver can not only receive system broadcasts, but also receive customized broadcasts1. Define a broadcast receiver
Copy Code code as follows:
public class Myreceiver extends Broadcastreceiver
{
Public Myreceiver ()
{
LOG.I (TAG, "myreceiver");
}
Getaction () of intent can be used to distinguish between different broadcasts received
@Override
public void OnReceive (context ar
"); Toast. makeText (context, "your cell phone is underpowered, please recharge in time", Toast. LENGTH_SHORT ). show ();}}}
V,Normal broadcast and ordered Broadcast
The above example is just a receiver to receive broadcasts. If multiple receivers register the same
Type of broadcast:1. Standard broadcast (normal broadcat)Broadcasts that are executed completely asynchronously, all broadcast receivers receive broadcast messages at the same time.High efficiency, but cannot be truncated.2. Orderly BroadcastingSimultaneous broadcast, only o
When a situation occurs on an Android system, all programs must be notified of processing, such as low power, and the broadcast intent object can be used to broadcast information.The operating mechanism consists of two parts: The program that sends out the intent object, the program that listens to the broadcast information (
Straight to the subject, some definitions of the broadcast I think as long as it is a qualified primary Android development This all know, I have to do is how to use broadcast receiver.1. How to listen to the system broadcast?Android system has many built-in system broadcasts: Phone, SMS, time, region, battery level, n
Alas ... Yesterday wrote the blog, was the blog Park Management Group to abandon ... Sad!Yesterday, thanks to the basic use of the radio, today go deep in the steak, tomorrow continue to write about the radio blog.Much of what was said yesterday was about the reception of system broadcasts and the reception of system broadcasts, and now the use of custom broadcasts. Say the standard broadcast first, take yesterday static registration that example. It'
BroadcastReceiver broadcast receiver (3)-transmit data between applications using Broadcast??
The TestBroadcastA application is as follows:
MainActivity is as follows:
Package cc. testbroadcasta; import android. OS. bundle; import android. app. activity;/*** Demo Description: * use broadcast to transmit data between ap
);
SYSTEM.OUT.PRINTLN (address);
System.out.println (body);
Interrupt phone receive Operation
Abortbroadcast ();
}
Monitor the call.
1. Define broadcast receiver receive Android.intent.action.NEW_OUTGOING_CALL2. Need permission
Copy Code code as follows:
3. Use the Getresultdata () and Setresultdata () methods in the OnReceive method to get and set the phone nu
We described the broadcast mechanism of the Android system, in essence, it is a message subscription/advertisement mechanism, so the first step to use such a message-driven model is to subscribe to the message, and for Android applications, the subscription message is actually a register broadcast receiver, This article explores how the Android app will register
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.