From Activity you send data with intent as:
Bundle bundle = new Bundle();
bundle.putString("text", "From Activity");
// set Fragmentclass Arguments
DevicesFragment devices = new DevicesFragment();
devices.setArguments(bundle);
getSupportFragmentManager().beginTransaction().add(R.id.fragment, devices, "devices").commit();
and in DevicesFragment onCreateView method:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle bundle = getArguments();
if(bundle != null) {
String value = bundle.getString("text");
}
return inflater.inflate(R.layout.fragment, container, false);
}