开发者

OnResume() not called by Pressing back Button in ActivityGroup

开发者 https://www.devze.com 2023-03-26 21:23 出处:网络
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.

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

精彩评论

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