当前位置:   article > 正文

Android无序广播的实现代码_无序广播实现

无序广播实现

首先大多时候都是无序广播与有序广播的区别,那今天先讲讲无序广播.

咱们先来讲一个广播发送者和广播接受者的案例

1.如图:


熟悉一下广播传播者与广播接受者的属性

下面会带大家熟悉代码,简单的演示一下

2.代码演示:

发送者的一个简单布局

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. xmlns:app="http://schemas.android.com/apk/res-auto"
  5. xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  6. android:orientation="vertical"
  7. android:layout_height="match_parent" tools:context="com.example.my_android_sender.MainActivity">
  8. <EditText
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. android:id="@+id/et_main_content"
  12. android:hint="请输入要发送的内容"
  13. />
  14. <Button
  15. android:layout_width="match_parent"
  16. android:layout_height="wrap_content"
  17. android:text="发送"
  18. android:onClick="send"
  19. />
  20. </LinearLayout>


发送者的activity,在此之中,我用了黏性广播

package c
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/350224
推荐阅读
相关标签
  

闽ICP备14008679号