androidandroid-activityfragmentrewardedvideoad

Loading a fragment upon a specific condition


I have an issue please help me out. I am building an android application and I have successfully integrated Rewarded video ads to it.

I want to show a fragment or auto redirect to a specific fragment when the below condition is met:

@Override
    public void onRewarded(RewardItem rewardItem) {
// I want to redirect the user to a particular fragment here. 
}

So Please help me out, if there is any other way to achieve this then please let me know.


Solution

  • Use Fragment Manager and Fragment Transaction Manager for this.

    getFragmentManager().beginTransaction().replace(R.id.your_framelayout_id, new your_fragment()).commit();