• BroadcastReceiver


    目录

    • 接收广播
      • 动态接收广播
      • 静态接收广播
    • 发送广播
      • 发送标准广播
      • 发送有序广播
      • 发送本地广播

    接收广播

    • 动态

      • IntentFilter 定义接收广播的类型
      • MyBroadcastReceiver extends BroadcastReceiver
      • registerBroadcastReceiver(IntentFilter, BroadcastReceiver)
      • registerBroadcastReceiver(BroadcastReceiver)
    • 静态

      • 定义BroadcastReceiver类
      • manifest中注册
      • 添加IntentFilter

    发送广播

    • 发送标准广播
    Intent intent = new Intent();
    intent.setAction("com.example.broadcasttest.MY_BROADCAST");
    sendBroadcast(intent);
    
    • 发送有序广播

    sendOrderedBroadcast(intent, null);
    广播接收器1
    <intent-filter android:priority="100">
    广播接收器2默认,
    则1优先接收到广播
    并且1可以截断广播,在onReceiver()方法中使用
    abortBroadcast();

    • 发送本地广播

    new LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

    Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind
  • 相关阅读:
    进程池和线程池
    TCP并发、GIL、锁
    进程间通信
    装饰器与反射
    装饰器大全
    面向对象三大特征: 封装 继承 多态
    面向对象 魔术方法
    魔术方法
    ubuntu 中导 tarfile,win 不亲切
    os VS shutil
  • 原文地址:https://www.cnblogs.com/s3abiscuit/p/7202594.html
Copyright © 2020-2023  润新知