• 安卓——BroadcastReceiver




    package com.example.administrator.myapplication_reciver;

    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.widget.Toast;

    /**
    * Created by Administrator on 2018/1/1.
    */

    public class Myreciver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

    String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
    Toast.makeText(context,s,Toast.LENGTH_LONG).show();

    }
    }

    配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
    <intent-filter>
    <action android:name="reciver" />
    </intent-filter>
    </receiver>


    3 Intent in =new Intent("reciver");
    in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
    sendBroadcast(in);
    send(v);

    package com.example.administrator.myapplication_reciver;

    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.widget.Toast;

    /**
    * Created by Administrator on 2018/1/1.
    */

    public class Myreciver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

    String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
    Toast.makeText(context,s,Toast.LENGTH_LONG).show();

    }
    }

    配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
    <intent-filter>
    <action android:name="reciver" />
    </intent-filter>
    </receiver>


    3 Intent in =new Intent("reciver");
    in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
    sendBroadcast(in);
    send(v);


    安卓——BroadcastReceiver
    package com.example.administrator.myapplication_reciver;

    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.widget.Toast;

    /**
    * Created by Administrator on 2018/1/1.
    */

    public class Myreciver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

    String s=intent.getStringExtra("a")+intent.getStringExtra("a1");
    Toast.makeText(context,s,Toast.LENGTH_LONG).show();

    }
    }

    配置文件 AndroidManifest.xml <receiver android:name=".Myreciver">
    <intent-filter>
    <action android:name="reciver" />
    </intent-filter>
    </receiver>


    3 Intent in =new Intent("reciver");
    in.putExtra("a1","第二条是 你好啊,交个盆友吧!");
    sendBroadcast(in);
    send(v);

  • 相关阅读:
    SQL 查询第n条到第m条的数据
    Linq 中查询一个表中指定的字段
    归并排序与逆序对
    补码拾遗
    堆排序
    It is time to cut the Gordian Knot!
    蛋疼
    [引]Microsoft Visual Studio .NET 2005 预发行版
    关于VS2005中自动生成TableAdapter的事务处理
    关于释放ASPNET进程的内存占用问题.
  • 原文地址:https://www.cnblogs.com/embaobao/p/10720860.html
Copyright © 2020-2023  润新知