Not able to send data by using bundle

i want to send a string data from activity to fragment but at fragment it is not receiving my data …and giving null pointer exception

use after setArguments.

    getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.fl2, countUp_fragment, null)
                .commit();

And for getArguments use

 if(getArguments()!=null) {
            String subtext = getArguments().getString("key");
            tv2.setText(subtext);
        }

For the first time when the fragment is created the getArguments is null then when activity is loaded the you need to set arguments and replace the fragment to see the changes.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.