Can't Implement GetIntent(); Method In Fragment
I try to implement getIntent(); in Fragment and display text but I get Cannot resolve method 'getIntent()' Here is part of Fragment3.java public View onCreateView(LayoutInflater in
Solution 1:
You can use:
getActivity().getIntent();
Or you can pass data to fragment directly using arguments:
Bundle args = new Bundle();
args.putBoolean("Key Answer", true);
Fragment f = new YourFragment();
f.setArguments(args);
Make sure you set arguments before fragment is added to FragmentManager.
Solution 2:
getIntent()
is a Activity class method which isn't directly accessible from your fragment. Try calling getActivity.getIntent()
to get the Activity in context first.
Post a Comment for "Can't Implement GetIntent(); Method In Fragment"