2016-11-18 49 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"); 
相关问题