Usage of sendBroadcast()

前端 未结 2 1719
眼角桃花
眼角桃花 2021-01-01 21:25

sendBroadcast() - Should it be called inside Activity? I am trying to call sendBroadcast() from my method of utility-class which doesn\'t extend Activity. I am getting compi

相关标签:
2条回答
  • 2021-01-01 22:15

    If you extend Application object (main entry that is being called before the your first Activity) then you can keep a shared singletone for your application.

    0 讨论(0)
  • 2021-01-01 22:20

    You should pass the context from activity class to utility class to access the specific application resources like startActivity, sendBroadcast, etc.

    context.sendBroadcast(intent);
    
    0 讨论(0)
提交回复
热议问题