0

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?

Android
  • 388
  • 2
  • 3
  • 14

1 Answers1

0

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

Rajnish Mishra
  • 826
  • 5
  • 21
  • its giving "The method onNewIntent(Intent) of type className must override" or implement a supertype method error and for quick fix.. remove @override its showing...... – Android Aug 05 '14 at 13:08
  • Put your onNewIntent in a SherlockActivity and it should work – Rajnish Mishra Aug 05 '14 at 13:12