开发者

OnResume() not called by Pressing back Button in ActivityGroup

As ActivityGroup manages the Activities in the form of view, so when I try to return back to the Parent Activity that called the child Activity in ActivityGroup the onResume() is not being called.

I tried calling the OnResume() like this.

((Activity)view.getContext()).onResume();

But its not working, instead finish() is working is fine for me.

((Activity)view.getContext()).finish();

So, I am able to get the Activity from the View, but not able to call the onResume(), any idea wil开发者_如何学编程l be appreciable.


Try this, when you press back button using ActivityGroup.

public void back()
    {
     if ( arrList.size() > 1 )
      {
       arrList.remove(arrList.size() - 1);
       View v = arrList.get(arrList.size() - 1);

       Activity_name object = ((Activity_name)v.getContext());
       object.onResume();
       setContentView(v);
      }
     else {
      this.finish();
     }
    }


onResume is a lifecycle method called by OS when activity comes to the top of the stack. You can't call it directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜