2016-11-18 45 views
-2

根據我在BroadcastReceiver中的用例,我得到的布爾值是true或false。然後我將這個價值廣播給我的活動。以下是我的代碼如何接收Activity中的數據

boolean flag12 = MtpClient.isUSBDevice(usbDevice); 
Bundle extras = intent.getExtras(); 
Intent i = new Intent("broadCastName");     
intent.putExtra("MYMTP",flag12); 
mContext.sendBroadcast(intent); 

如何在活動中接收此內容。我需要在我的活動中再創作一個廣播嗎?因爲我在做同一活動的sendBroadcast。

感謝

回答

0

您可以在活動中使用getBoolean()

Boolean yourBool = getIntent().getExtras().getBoolean("MYMTP"); 
相關問題