Android BroadcastReceiver within Activity

后端 未结 7 1470
后悔当初
后悔当初 2020-11-28 23:59

I\'m just trying this little sample project, all it does: Activity one has a Button that sends a Broadcast. Activity two displays a toast when received. Below is the code, t

7条回答
  •  醉话见心
    2020-11-29 00:11

    You need to define the receiver as a class in the manifest and it will receive the intent:

    
        
          
        
      
    
    

    And you don't need to create the class manually inside ToastDisplay.

    In the code you provided, you must be inside ToastDisplay activity to actually receive the Intent.

提交回复
热议问题