package com.example.administrator.myapplication_reciver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

/**
* Created by Administrator on 2018/1/1.
*/

public class Myreciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
Toast.makeText(context,s,Toast.LENGTH_LONG).show();

}
}

配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
<intent-filter>
<action android:name="reciver" />
</intent-filter>
</receiver>


3 Intent in =new Intent("reciver");
in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
sendBroadcast(in);
send(v);

package com.example.administrator.myapplication_reciver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

/**
* Created by Administrator on 2018/1/1.
*/

public class Myreciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
Toast.makeText(context,s,Toast.LENGTH_LONG).show();

}
}

配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
<intent-filter>
<action android:name="reciver" />
</intent-filter>
</receiver>


3 Intent in =new Intent("reciver");
in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
sendBroadcast(in);
send(v);


安卓——BroadcastReceiver
package com.example.administrator.myapplication_reciver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

/**
* Created by Administrator on 2018/1/1.
*/

public class Myreciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
Toast.makeText(context,s,Toast.LENGTH_LONG).show();

}
}

配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
<intent-filter>
<action android:name="reciver" />
</intent-filter>
</receiver>


3 Intent in =new Intent("reciver");
in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
sendBroadcast(in);
send(v);

安卓——BroadcastReceiver的更多相关文章

  1. 安卓组件-BroadcastReceiver

    [转]http://emilyzhou.blog.51cto.com/3632647/685387 一.BroadcastReceiver的简介 用于异步接收广播Intent,广播Intent的发送是 ...

  2. Android中BroadcastReceiver的两种注册方式(静态和动态)详解

    今天我们一起来探讨下安卓中BroadcastReceiver组件以及详细分析下它的两种注册方式. BroadcastReceiver也就是"广播接收者"的意思,顾名思义,它就是用来 ...

  3. 手机APP开发:学JAVA转安卓APP开发是不是很容易?

    成都亿合云商小编为您分享:Android开发是以Java语言为基础的,Android 虽然使用Java 语言作为开发工具,但是在实际开发中发现,还是与Java SDK 有一些不同的地方.Android ...

  4. 安卓版App开发心得

    从2016年4月到6月主要做的工作是网站的开发,而6月到现在2016年8月初,主要做的工作是Android和IOS两种App的开发,又以Android为主. 将这段时间的Android开发心得记录如下 ...

  5. 安卓App流量统计

    http://keepcleargas.bitbucket.org/2013/10/12/android-App-Traffic.html 安卓App流量统计 12 OCT 2013 android流 ...

  6. 安卓Android面试题大全

    56个问题都是经常用到的,可以深入研究下,也是必须掌握的开发必备知识. 安卓Android面试题汇总 搜集了一些Android面试题目,供将要面试或者正在面试的朋友参考. 1, 谈谈你对Activit ...

  7. 安卓第十一天笔记-Intent与inter-filter配置

    安卓第十一天笔记-Intent与inter-filter配置 Intent与inter-filter配置 1.Intent对象简述 Android应用中有包含三种重要组件:Activity,Servi ...

  8. 安卓任意两个或多个Fragment之间的交互与刷新界面

    平时项目中遇到一个问题:在子fragment中刷新父fragment的界面,通俗的说也就是在任何一个fragment中来刷新另一个fragment.大家都知道activity和fragment之间的交 ...

  9. 安卓蓝牙技术Bluetooth使用流程(Bluetooth详解)

    一:蓝牙设备之间的通讯首要包含了四个进程 设置蓝牙设备 寻觅局域网内也许或许匹配的设备 衔接设备 设备之间的数据传输 二:详细编程完结 1. 发动蓝牙功用 首要经过调用静态办法getDefaultAd ...

随机推荐

  1. 论文笔记:Show, Attend and Tell: Neural Image Caption Generation with Visual Attention

    Show, Attend and Tell: Neural Image Caption Generation with Visual Attention 2018-08-10 10:15:06 Pap ...

  2. 深度学习课程笔记(七):模仿学习(imitation learning)

    深度学习课程笔记(七):模仿学习(imitation learning) 2017.12.10 本文所涉及到的 模仿学习,则是从给定的展示中进行学习.机器在这个过程中,也和环境进行交互,但是,并没有显 ...

  3. Tutorial: Implementation of Siamese Network on Caffe, Torch, Tensorflow

    Tutorial: Implementation of Siamese Network with Caffe, Theano, PyTorch, Tensorflow  Updated on 2018 ...

  4. Twenty score

    1.上图中有两个人对读书的看法有较大的不同. There are two people in the cartoon who treat books in completely different w ...

  5. Shell脚本(三)

    摘自:菜鸟教程 http://www.runoob.com/linux/linux-shell-echo.html Shell命令 1. echo命令 字符串输出 echo "OK! \c& ...

  6. 异步编程- async和await

    使用目的 避免阻塞主线程 提高程序响应能力 C#中使用 C# 中的 Async 和 Await 关键字是异步编程的核心. 疑惑 The async and await keywords don't c ...

  7. Mac python 2.X 升级到 3.X

    Mac OS X10.9默认带了Python2.7,不过现在Python3.3.3出来了,如果想使用最新版本,赶紧升级下吧.基本步骤如下. 第1步:下载Python3.3 下载地址如下: Python ...

  8. Qt中中文字符 一劳永逸的解决方法

    QT中中文字符问题,有没有一劳永逸的解决方法? 目前遇到有以下问题 1.字符串中有中文时,编译提示"常量中含有换行符" 2.在控制台窗口输出中文时无法正常显示,中文全部显示为? 目 ...

  9. 前端调用接口报错看不到报错响应时 console.dir

    console.dir() 可以看到很多.log看不到的属性和方法

  10. vue定义全局方法 调用其他组件的方法

    官网的写法  vue实例.$on就可以在根实例上定义全局方法 this.$root就是获取根实例  如果没有根实例 就表示当前实例 this.$root.$on 不需要.eventHub 不需要下面这 ...