有序广播怎么在Android应用中进行发送?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。Android系统提供了两种广播类型,一种是有序广播,一种是有序广播。(1)无序广播是完
有序广播怎么在Android应用中进行发送?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
Android系统提供了两种广播类型,一种是有序广播,一种是有序广播。
(1)无序广播是完全异步执行,发送广播时所有监听这个广播的广播接收者都会收到此消息,但接收的顺序不确定。
(2)有序广播是按照接收者的优先级接收,只有一个广播接收者能接收信息,在此广播接收者中逻辑执行完毕后,才会继续传递。
实验要求:通过sendOrderedBroadeast()发送一条有序广播
在activity-main.xml布局文件中代码如下:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="Http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:background="@drawable/stitch_one" tools:context="cn.edu.bzu.orderedbroadcast.MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:onClick="send" android:layout_marginTop="50dp" android:text="发送有序广播" android:paddingLeft="5dp" android:paddingRight="5dp" android:background="#FFD202" android:textSize="20sp" /> </RelativeLayout>
--结束END--
本文标题: 有序广播怎么在Android应用中进行发送
本文链接: https://www.lsjlt.com/news/222926.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0