Android from ignorance to knowledge-No. 7 and androidno.7

Source: Internet
Author: User

Android from ignorance to knowledge-No. 7 and androidno.7

 

The ip address dialer previously used broadcast events provided by the system to listen for outbound calls. In some cases, we need to set broadcast events to meet specific needs. OK. Today, we use a status monitoring module to send alarm messages to a 3G module.

First, define a 3G module to receive specific broadcasts:

<TextView android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_centerHorizontal = "true" android: layout_centerVertical = "true" android: text = "I Am a 3G module ~~~~ "/>

Then set its custom broadcast events:

<receiver android:name=".MyBro">            <intent-filter>                <action android:name="com.heng.lh"/>            </intent-filter></receiver>

HereCom. heng. lh is a broadcast event defined by us to receive signals from specific channels.

Then let's "sp" it. If a custom broadcast is sent, a prompt will be sent to the user.

Public void onReceive (Context context, Intent intent) {Toast. makeText (context, "a broadcast event is detected", 1). show ();}


The module that receives the broadcast is ready, and then the module that sends the broadcast is set. A button is required on the main interface to send the alarm information to the 3G module:

<Button android: onClick = "click" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_centerHorizontal = "true" android: layout_centerVertical = "true" android: text = "send information to 3G module"/>

Let's write down this click event, new out an intent, and then set its action, that is, the custom "com. heng. then, send the message with sendBroadcast.

Public void click (View view) {Intent intent = new Intent (); intent. setAction ("com. heng. lh "); // send the alarm information to the 3G module sendBroadcast (intent );}

In this way, the 3G module receives a broadcast message, and a simple custom broadcast event is created.


Answer: from ignorance to knowledge,

B
 
From ignorance to knowledge, it means not understanding, or being immature to maturity.

From ignorance to ignorance, you can accept some nonsense words with patience.
 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.