0

In My application have activity with fragment and another activity with fragment if user press back button from second activity fragment .It should go to first activity fragment I have tried using in fragment

getActivity.finish()

In activity finish()

I am getting fragment Instantiate exception

Thanks

user386430
  • 4,837
  • 13
  • 41
  • 45
  • i think android handles this scenario automatically on back pressed. What happens if you don't override `onBackpressed` and let android handle back press? – Abhishek V Feb 26 '15 at 07:18
  • @abhisek it is going to fragment – user386430 Feb 26 '15 at 07:22
  • Do not call `super.onBackPressed` in that case then just call `finish()` in `onBackpressed`Method of activity. – Abhishek V Feb 26 '15 at 07:24
  • look into the following..http://stackoverflow.com/questions/7992216/android-fragment-handle-back-button-press – Born To Win Feb 26 '15 at 07:29
  • Use addtobackstack() in the first activity it will add the first activity into the stack.And on back press the first activity will be there. – Akash Feb 26 '15 at 08:48

0 Answers0