How to OnNewIntent function inside SherlockFragment?

794 Views Asked by At

In my application I am using SherlockFragment for Sidenavigation menu and as well as Tab fragments.

Here I got a position to use OnNewIntent function inside SherlockFragment. But its returning an error like "The method onNewIntent(Intent) of type classname must override or implement a supertype method".

code:

 public class MyClass extends SherlockFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Get the view from Twitter.xml
        View view = inflater.inflate(R.layout.activity, container, false);

            return view;
    }
        @Override
        protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);

        }
    }

So can any one suggest me how to solve this?

1

There are 1 best solutions below

2
Rajnish Mishra On

If you want to access onNewIntent inside fragment it is impossible onNewIntent is a part of activity so you need to place this method with override in you activity and access the intent via

getActivity().getIntent()

You need to put onNewIntent inside a Activity

public class MyClass extends SherlockActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
          //inside onNewIntent update your origional Intent by calling 
         setIntent(intent

    }
}

Now every call for getIntent() on this activity will give you the latest intent