第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

如何使用LocalBroadcastManager?

如何使用LocalBroadcastManager?

暮色呼如 2019-05-27 16:53:49
如何使用LocalBroadcastManager?LocalBroadcastManager如谷歌文檔和服務(wù)廣播文檔中所述如何使用/定位?我試圖谷歌它,但沒有可用的代碼開始?文件說如果我想在我的應(yīng)用程序進(jìn)程內(nèi)部進(jìn)行廣播,我應(yīng)該使用它,但我不知道在哪里尋找這個(gè)。任何幫助/評論?更新:我知道如何使用廣播,但不知道如何LocalBroadcastManager在我的項(xiàng)目中使用。
查看完整描述

4 回答

?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊

在接收結(jié)束時(shí):

  • 首先注冊LocalBroadcast Receiver

  • 然后處理onReceive中的傳入意圖數(shù)據(jù)。

      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
    
          LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
          lbm.registerReceiver(receiver, new IntentFilter("filter_string"));
      }
    
      public BroadcastReceiver receiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              if (intent != null) {
                  String str = intent.getStringExtra("key");
                  // get all your data from intent and do what you want 
              }
          }
      };

發(fā)送結(jié)束時(shí):

   Intent intent = new Intent("filter_string");
   intent.putExtra("key", "My Data");
   // put your all data using put extra 

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


查看完整回答
反對 回復(fù) 2019-05-27
  • 4 回答
  • 0 關(guān)注
  • 1173 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號