android - How to finish an activity just before starting a Fragment? -
i have activity contains button , starts fragment when clicked.but need finish current activity when starting fragment.how possible?i tried calling finish() after starting fragment.but not working.
android.app.fragmentmanager fm = getfragmentmanager(); detailfragment dialog_fragment = new detailfragment("events",name,id); dialog_fragment.show(fm, "detailscreen"); finish();
call getactivity().finish();
fragment finish activity.
however, careful. getactivity()
null
. in case, don't call finish()
. activity destroyed.
Comments
Post a Comment