1.在布局文件里面加入按钮,等会发送广播
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context=".MainActivity3">
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送广播">
2.使用广播的第一步当然是创建一个广播接受者
public class MyBrodestReciver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
//判断action是否为添加的action,如果是则toast
String