Skip to content Skip to sidebar Skip to footer

Null Pointer Exception Passing Data From Activity To Fragment

I have the url value in the MainActivity page and i need to pass this url value from ACtivity to Fragment. But when i click the button i'm getting null exception on the line of Str

Solution 1:

You need to commit after you set the fragments arguments. Change your code to this:

About fragobj=new About();    
Bundle bundle=new Bundle();
bundle.putString("btn_url", URL);        
fragobj.setArguments(bundle);
getFragmentManager().beginTransaction();
.replace(R.id.frame_container, fragobj, "TAG_FRAGMENT");
.addToBackStack(null);
.commit(); 

Post a Comment for "Null Pointer Exception Passing Data From Activity To Fragment"