title: Intent to activity is not working while using fragment for card view on click
body: <p>I am using a <code>fragment</code> to hold <strong>4 card views</strong>, which should start a new activity on click. It can display the <code>toast</code> I generate which shows that the click function is working but it is unable to activate the intent.</p>
  
  <p>I have tried using several names for the activity and also </p>
  
  <pre><code>Intent intent = new Intent (getActivity(), activity name.class)
  </code></pre>
  
  <p>code to start activity</p>
  
  <pre><code>package com.example.eb.ui.home;
  import ...
  public class HomeFragment extends Fragment implements View.OnClickListener{
      private HomeViewModel homeViewModel;
      public View onCreateView(@NonNull LayoutInflater inflater,
                               ViewGroup container, Bundle savedInstanceState) {
    homeViewModel = ViewModelProviders.of(this).get(HomeViewModel.class);
          View root = inflater.inflate(R.layout.fragment_home, container, false);
          final CardView  java = root.findViewById(R.id.javacardId);
          final CardView  html = root.findViewById(R.id.htmlcardId);
          final CardView  c_prog = root.findViewById(R.id.C_cardId);
          final CardView  cpp = root.findViewById(R.id.cppcardId);
             //set on click listener
          java.setOnClickListener(this);
          html.setOnClickListener(this);
          cpp.setOnClickListener(this);
          c_prog.setOnClickListener(this);
               return root;
      }
      @Override
      public void onClick(View v) {
          Intent i;
          switch(v.getId()){
              case R.id.javacardId :
                  i = new Intent(this,html.class);
                  startActivity(i);
                     break;
              case R.id.htmlcardId :
                  i = new Intent(this,html_prog.class);
                  startActivity(i);
                   break;
              case R.id.cppcardId :
                  i = new Intent(this,cpp_prog.class);
                 startActivity(i);
                 break;
              case R.id.C_cardId :
                  i = new Intent(this,c_prog.class);
                  startActivity(i);
                  break;
              default: break;
          }
  
      }
  }
  ---
  </code></pre>
  
  <p>I expect the <strong>card view</strong> in that <code>fragment</code> to open up new activity</p>