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:
Bundleargs=newBundle();
args.putBoolean("Key Answer", true);
Fragmentf=newYourFragment();
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"