Communication between TabActivity and the embedded activity

后端 未结 5 832
Happy的楠姐
Happy的楠姐 2021-01-14 15:44

I am trying to figure out the best practice of communication between a TabActivity and the child activity embedded in this TabActivity.

In my TabActivity, there is a

5条回答
  •  旧时难觅i
    2021-01-14 16:48

    Seems fine. A couple of notes:
    - I see no reason for synchronization.
    - I'd replace

    ChildActivity.s_childActivity.changeUI();
    

    with

    if(ChildActivity.s_childActivity != null){
        ChildActivity.s_childActivity.changeUI();
    }
    

    or even

    try{
        ChildActivity.s_childActivity.changeUI();
    } catch(Exception e){
        //log
    }
    

    for added paranoid safety. :)

提交回复
热议问题