android - Close Activity using Fragment -
introduction
i have activitya
starts fragment
when click button. using intent can't start fragment, i've created second activity, let's call activityb
acts bridge between activitya
, fragment
.
the structure : activitya --> activityb --> fragment
functionality
the functionality activitya
, start fragment
, request data, , bring data activitya
.
for use startactivityforresult()
in activitya
call activityb
. in activityb
start fragment
way:
fragment fragment = new fragment(); fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); ft.add(android.r.id.content, fragment).commit();
when finish must on fragment
, use setresult()
send data activtya
.
problem
the thing have started activityb
initialize fragment
, when returning data fragment
activitya
, activityb
still 1 opened, , activitya
remains on background.
this makes me not able process requsted data, activitya
continues on background.
so, need know how close activityb
when finish operations in fragment
, go activitya
, make visible.
you can use method getactivity().finish()
method in fragment
close activityb
.
Comments
Post a Comment