Android Broadcast 了解广播

Android Broadcast 了解广播1.了解广播机制2.接受飞行模式广播的一个简单示例(1).继承广播接收者/**Copyright(c)2016AllRightsReservedByFFCS*/packagecom.alan.broadcast1;importandroid.content.BroadcastReceiver;importandroid

1.了解广播机制

Android Broadcast 了解广播

2.接受飞行模式广播的一个简单示例

(1).继承广播接收者

/*  * Copyright (c) 2016 All Rights Reserved By FFCS  */  package com.alan.broadcast1;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.util.Log;/**  * Created by CanxinQiu on 2016/8/31.  * Description: Broadcast lesson is listen system,include register receiver in Manifest  * and in BroadcastReceiver to receive the action,than do something.  */ public class MyReceiver extends BroadcastReceiver{    @Override    public void onReceive(Context context, Intent intent) {        Log.i("Broadcast","Received");        Log.i("Broadcast",context.getPackageName());        Log.i("Broadcast",intent.getAction());    }}


(2)在Android Manifest里注册

<receiver android:name=".MyReceiver">    <intent-filter>        <action android:name="android.intent.action.AIRPLANE_MODE"></action>    </intent-filter></receiver>

今天的文章Android Broadcast 了解广播分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/23722.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注