一、先说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. Android中使用shape来定义控件

    本文章转接于:http://kofi1122.blog.51cto.com/2815761/521605 Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对s ...

  2. iOS-OC-基础-NSDictionary常用方法

    /*=============================NSDictionary(不可变字典)的使用=========================*/ //————————————————— ...

  3. ES6 let和const命令

    一.let定义变量 { let a = 1;} console.log(a);只在let所在的代码块有效,console的结果是a is not defined,报错. 不存在var的变量提升,即使用 ...

  4. C++ Primer Plus 6th 读书笔记 - 第6章 分支语句和逻辑运算符

    1. cin读取错误时对换行符的处理 #include <iostream> using namespace std; int main() { double d; char c; cin ...

  5. js经典代码技巧学习之一:使用三元运算符处理javascript兼容

    window.Event = { add: function() { //使用条件表达式检测标准方法是否存在 return document.addEventListener ? function(a ...

  6. linux下tar用法

    以下是linux下tar的用法,转一下,以便方便自己看(这里没把rar,zip类的转过来,一般rar,zip在linux下基本没人用,基本上是zip,unzip,rar,unrar,这些命令,并且ra ...

  7. Django1.7官方文档中的tutorial——翻译

    写下你的第一个Django应用,第一部分 让我们通过例子来学习. 通过这篇指南,我们将会带你浏览一遍一个基本投票应用的创建. 它由两部分组成: 1一个让人们查看投票和进行投票的公共站点 2一个让你添加 ...

  8. Dropdownlist的onchange事件应用

    function selectDpList(dp) { var sIndex = dp.selectedIndex;//返回选中是第几项 0,1.... var sText = dp.options[ ...

  9. codeforce343A

    题目地址:http://codeforces.com/problemset/problem/343/A 比赛的时候就囧了,只推出a<b的时候最少需要b个电阻. 后来看了题解,知道 题意:用最少的 ...

  10. 【转】Linux驱动模块编译进内核中

    原文网址:http://blog.chinaunix.net/uid-29287950-id-4573481.html BQ27501驱动编译进内核 一.       驱动程序编译进内核的步骤 在 l ...