title: getActivity().getComponentName() into Fragment Nullpointerexception
body: <p>In a multiple tabs app,i added an expandable listview and a searchview in one of the tabs(Tab2).I had an error on getComponentName() as its not supported for fragment.So i added the getActivity().getComponentName(). There is no errors but NullpointerException when running it on this line.The app crashes. Any ideas?<br>
  Here are the code's important lines:</p>
  
  <pre><code>public class Tab2 extends Fragment implements SearchView.OnQueryTextListener,SearchView.OnCloseListener{
  private SearchView search;
  private MylistAdapter listAdapter;
  private ExpandableListView myList;
  private ArrayList&lt;Continent&gt; continentList = new ArrayList&lt;Continent&gt;();
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.tab2, container, false);
      SearchManager searchManager = (SearchManager)  getActivity().getSystemService(Context.SEARCH_SERVICE);
      search = (SearchView) getActivity().findViewById(R.id.search);
      search.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
      search.setIconifiedByDefault(false);
      search.setOnQueryTextListener(this);
      search.setOnCloseListener(this);
  
      displayList();
      expandAll();
      return rootView;
  }
  
  
  
  private void expandAll(){
  
      int count = listAdapter.getGroupCount();
      for (int i=0; i&lt;count; i++)
      {
          myList.expandGroup(i);
      }
  }
  
  private void displayList() {
  
      // display the list
      loadSomeData();
  
      // get reference to the ExpandableListView
      myList = (ExpandableListView) getView().findViewById(R.id.expandableList);
      // create the adapter by passing your ArrayList data
      listAdapter = new MylistAdapter(getActivity(), continentList);
      // attach the adapter to the list
      myList.setAdapter(listAdapter);
  
  }
  </code></pre>
  
  <p>and the activity:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity" &gt;
  
  &lt;SearchView
      android:id="@+id/search"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true" /&gt;
  
  &lt;ExpandableListView
      android:id="@+id/expandableList"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/search" &gt;
  &lt;/ExpandableListView&gt;
  </code></pre>
  
  <p></p>