一、先说Service服务。

  1、利用setAction()方法来指定启动的Service服务

 Intent intent = new Intent();
intent.setAction("ServiceAction");
startService(intent);

  2、使用Intent的构造函数类添加Activity内容

 Intent intent = new Intent("ServiceAction");
startService(intent);

  3、和Activity之间跳转类似

 Intent intent = new Intent(MainActivity.this,ServiceTest.class);
startService(intent);

二、再看Broadcast广播

  1、利用setAction()方法来指定发送的Broadcast广播

 Intent intent = new Intent();
intent.setAction("BroadcastAction");
sendBroadcast(intent);

  2、使用Intent的构造函数类添加Activity内容

 Intent intent = new Intent("BroadcastAction");
sendBroadcast(intent);

  3、和Activity之间跳转类似

 Intent intent = new Intent(MainActivity.this,BroadcastTest.class);
sendBroadcast(intent);

Android 启动Service服务和发送Broadcast广播的常用方法的更多相关文章

  1. Android中Service(服务)详解

    http://blog.csdn.net/ryantang03/article/details/7770939 Android中Service(服务)详解 标签: serviceandroidappl ...

  2. android 启动 service 的两种方式,及什么时候用哪个 android 什么时候用bindService

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha android  什么时候用bindService ============ 启动方式有 ...

  3. Android 中的消息传递,详解广播机制

    --------------------------------------广播机制简介--------------------------------------------- Android中的广 ...

  4. Android Service 服务(二)—— BroadcastReceiver

    (转自:http://blog.csdn.net/ithomer/article/details/7365147) 一. BroadcastReceiver简介 BroadcastReceiver,用 ...

  5. Android开发学习—— Broadcast广播接收者

    现实中:电台要发布消息,通过广播把消息广播出去,使用收音机,就可以收听广播,得知这条消息.Android中:系统在运行过程中,会产生许多事件,那么某些事件产生时,比如:电量改变.收发短信.拨打电话.屏 ...

  6. Android 综合揭秘 —— 全面剖释 Service 服务

    引言 Service 服务是 Android 系统最常用的四大部件之一,Android 支持 Service 服务的原因主要目的有两个,一是简化后台任务的实现,二是实现在同一台设备当中跨进程的远程信息 ...

  7. Android Service 服务(三)—— bindService与remoteService

    (转自:http://blog.csdn.net/ithomer/article/details/7366396)   一.bindService简介 bindService是绑定Service服务, ...

  8. Android中service的生命周期

    Service作为Android四大组件 Service Activity ContentProvider BroadcastReceiver 之一,应用非常广泛,和Activity一样,Servic ...

  9. Android Service总结03 之被启动的服务 -- Started Service

    Android Service总结03 之被启动的服务 -- Started Service 版本 版本说明 发布时间 发布人 V1.0 添加了Service的介绍和示例 2013-03-17 Sky ...

随机推荐

  1. Http请求和响应报文基础知识

    一 HTTP请求报文(http://en.wikipedia.org/wiki/List_of_HTTP_header_fields) 请求报文由三部分组成:请求行,请求头和请求体. 请求行:请求方法 ...

  2. Intellij Idea 配置database 连接SQL Server 2012

    首先确认通过TCP IP来连接连接SQLServer 2012     确保 Server Authentication选择了SQL Server and Windows Authentication ...

  3. asp.net缓存(二)

    ASP.NET页面局部缓存 有时缓存整个页面是不现实的,因为页的某些部分可能在每次请求时都需要变化.在这些情况下,只能缓存页的一部分.顾名思义,页面部分缓存是将页面部分内容保存在内存中以便响应用户请求 ...

  4. OC对象:封装、继承、多态的使用举例一

    // 该代码在网上找的视频中的例子,感觉很适合类和对象分不清楚的同学参考,仅供学习分享,谢谢 // 创建一个Pointtest类,用属性x.y表示点的坐标位置,求两点之间的距离,使用两种方法:类方法和 ...

  5. java实例变量及方法调用顺序

    public class Base { private String name="base"; public Base(){ sayHello(); } void sayHello ...

  6. HBase配置&启动脚本分析

    本文档基于hbase-0.96.1.1-cdh5.0.2,对HBase配置&启动脚本进行分析 date:2016/8/4 author:wangxl HBase配置&启动脚本分析 剔除 ...

  7. 深入C语言内存区域分配(进程的各个段)详解(转)

    原文地址:http://www.jb51.net/article/39696.htm 一般情况下,一个可执行二进制程序(更确切的说,在Linux操作系统下为一个进程单元,在UC/OSII中被称为任务) ...

  8. (原)Ubuntu16中安装cuda toolkit

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5655957.html 参考网址: https://devtalk.nvidia.com/default ...

  9. js 事件小结

    1,事件对象   e || window.event //ie   2, 取鼠标点击坐标 带有滚动条的   var top = document.documentElement.scrollTop | ...

  10. 第一章——第三节 intent的匹配原则

    问题 一.三种匹配原则 二.匹配的原理 三.隐式启动Activity,如何判断跳转的Activity是否存在. 判断Intent是否可行的两种办法.