Search code examples
javaandroidandroid-intentandroid-fragmentsactionbarsherlock

Undefined getIntent() method in SherlockFragment


Having a issue with the following error

The method getIntent() is undefined for the type

While using the following extends SherlockFragment {

Code

public View onCreateView(LayoutInflater inf, ViewGroup grp, Bundle icicle) {

    View v = inf.inflate(R.layout.activity_main, grp, false);
    web = (WebView) v.findViewById(R.id.webView);
    progressBar = (ProgressBar) v.findViewById(R.id.progressBar1);
    Bundle extras = getIntent().getExtras();
    String url;
    url = extras.getString("url");
    setHasOptionsMenu(true);
    return v;

Solution

  • Try using getActivity() ===> getActivity().getIntent().getExtras();

       Bundle extras = getActivity().getIntent().getExtras();