一、先说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. FULL JOIN 与 CROSS JOIN

    FULL JOIN 只要其中某个表存在匹配,FULL JOIN 关键字就会返回行.(返回JOIN 两端表的所有数据,无论其与另一张表有没有匹配.显示左连接.右连接和内连接的并集) FULL JOIN ...

  2. M - Candy Sharing Game

    Description A number of students sit in a circle facing their teacher in the center. Each student in ...

  3. codeforces 339C Xenia and Bit Operations(线段树水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Bit Operations Xenia the beginn ...

  4. imadjust函数分析一

    声明:本文涉及到的行数皆指本文提供的附件imadjust.m的代码中行数 本文只讨论imadjust函数是一种用法,即 J = IMADJUST(I,[LOW_IN; HIGH_IN],[LOW_OU ...

  5. Mysql表大小数据大小索引大小查询

    SELECT CONCAT(ROUND((INDEX_LENGTH+DATA_LENGTH)/1024/1024, 2), 'MB') AS '总大小',CONCAT(ROUND(DATA_LENGT ...

  6. Java的反射机制及应用实例

    一:什么是反射机制 简单的来说,反射机制指的是程序在运行时能够获取自身的信息.在Java中,只要给定类的名字,那么就可以通过反射机制来获得类的所有信息. 二:哪里用到反射机制 我们用过一些知识,但是并 ...

  7. Fedora19/18/17安装显卡驱动和无限网卡驱动

    一.安装nvidia显卡驱动 1. 切换到root用户          su - 2. 确定当前Linux内核及SELinux policy 是否为最新          yum update ke ...

  8. 编译安装httpd

    一.安装前的说明: httpd依赖于apr和apr-util所以在安装httpd之前要把这些东西都安装上去. 事先安装的依赖: yum -y install gcc gcc-c++ pcre-deve ...

  9. OSA-MAC: A MAC Protocol for Opportunistic Spectrum Access in Cognitive Radio Networks

    This full text paper was peer reviewed at the direction of IEEE Communications Society subject matte ...

  10. C# sql Helper

    using System; using System.Collections; using System.Collections.Generic; using System.Configuration ...