title: starting another activity (recyclerview list) by clicking on item
body: <p>My main activity (MainActivity) contains Recycler view with list of images and text in cardview. I am trying to put separate onCLick listener on each cardview so that when any card view is clicked, the next activity starts(MainActivity2). the cardview shows the channels image and names and when clicked on any channel, the user moves to the list of videos from that channel.
  <strong>MAinActivity code for recycler view</strong></p>
  <pre><code>
  private String[] channelnames={&quot;PTC Punjabi&quot;,&quot;Chakde TV&quot;,&quot;T-Series Punjabi&quot;, &quot;9X Tashan&quot;, &quot;Zee Punjabi&quot; };
      private int[] channelimages={R.drawable.ptcpunjabi, R.drawable.chakde, R.drawable.tseries, R.drawable.ninex, R.drawable.zeepunjabi};
      private List&lt;channel&gt; channelList=new ArrayList&lt;&gt;();
  
   thirdrecyclerView=findViewById(R.id.third_recycler_view);
          thirdrecyclerView.setHasFixedSize(true);
          channelList=new ArrayList&lt;&gt;();
          LinearLayoutManager thirdlinearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
          thirdrecyclerView.setLayoutManager(thirdlinearLayoutManager);
          for (int i=0;i &lt; channelnames.length;i++){
              channel channel=new channel(channelnames[i],channelimages[i]);
              channelList.add(channel);
          }
  </code></pre>
  <p>It loads as
  <a href="https://i.stack.imgur.com/R4je8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R4je8.png" alt="Horizontal recycler view" /></a>
  the interface <strong>ItemClickListener</strong> is defined as</p>
  <pre><code>package com.currentmedia.punjabinews;
  
          import android.view.View;
  
  public interface ItemClickListener {
      void onItemClickListener(View v, int position);
  }
  </code></pre>
  <p>the <strong>adapter and viewholder class</strong> is defined as;</p>
  <pre><code>public class channeladpater extends RecyclerView.Adapter&lt;channeladpater.Channelviewholder&gt; {
      private List&lt;channel&gt; channelList;
      Context ctx;
  
      public channeladpater(List&lt;channel&gt; channelList) {
          this.channelList = channelList;
          this.ctx=ctx;
      }
  
      @NonNull
      @Override
      public Channelviewholder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view,parent,false);
          return new Channelviewholder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull Channelviewholder holder, int position)
      {
          channel channel=channelList.get(position);
          holder.channelname.setText(channel.getChannelname());
          holder.channelimage.setImageResource(channel.getChannelimage());
  
          holder.setItemClickListener(new ItemClickListener() {
              @Override
              public void onItemClickListener(View v, int position) {
                  Intent intent=new Intent(ctx, MainActivity2.class);
                  ctx.startActivity(intent);
  
              }
          });
  
      }
  
      @Override
      public int getItemCount() {
          return channelList.size();
      }
  
      public static class Channelviewholder extends RecyclerView.ViewHolder implements View.OnClickListener{
          public TextView channelname;
          public CircleImageView channelimage;
          ItemClickListener itemClickListener;
  
          Channelviewholder(@NonNull View itemView) {
              super(itemView);
             this.channelname=itemView.findViewById(R.id.profile_name);
              this.channelimage=itemView.findViewById(R.id.profile_image);
              itemView.setOnClickListener(this);
          }
  
          @Override
          public void onClick(View v) {
  
              this.itemClickListener.onItemClickListener(v,getLayoutPosition());
  
  
          }
          public void setItemClickListener(ItemClickListener ic){
              this.itemClickListener=ic;
          }
      }
  }
  </code></pre>
  <p>the MAinActivity 2 is a Recycler View List of videos of channel using youtube DataAPI; the excerpet of code is;</p>
  <pre><code>public class MainActivity2 extends AppCompatActivity {
  
          RecyclerView recyclerView;
          ArrayList&lt;VideoDetails&gt; videoDetailsoArrayList;
         
          Intent intent=getIntent();
  </code></pre>
  <p>this is the screen shot of MainActivity2 that I want to run on click.
  <a href="https://i.stack.imgur.com/6mHmz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6mHmz.jpg" alt="MainActivity2" /></a></p>
  <p>But when I click on the icon the app crashes. the log error is shown as;</p>
  <pre><code>2020-09-18 00:34:33.348 30473-30514/com.currentmedia.punjabinews E/cr_VariationsUtils: Failed reading seed file &quot;/data/user/0/com.currentmedia.punjabinews/app_webview/variations_seed&quot;: /data/user/0/com.currentmedia.punjabinews/app_webview/variations_seed (No such file or directory)
  2020-09-18 00:34:33.697 30473-30553/com.currentmedia.punjabinews E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
  2020-09-18 00:34:33.698 30473-30553/com.currentmedia.punjabinews E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
  2020-09-18 00:34:34.255 30473-30593/com.currentmedia.punjabinews E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
  2020-09-18 00:34:34.256 30473-30593/com.currentmedia.punjabinews E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
  2020-09-18 00:34:34.923 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.022 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.062 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.121 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.170 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.194 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.197 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.213 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.215 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.224 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.266 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.269 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.270 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.273 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.278 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.289 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.293 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.297 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.301 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.306 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.308 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.313 30473-30473/com.currentmedia.punjabinews E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
  2020-09-18 00:34:35.470 30473-30596/com.currentmedia.punjabinews E/YouTubeAndroidPlayerAPI: Embed config is not supported in RemoteEmbeddedPlayer.
  2020-09-18 00:34:37.997 30473-30473/com.currentmedia.punjabinews E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.currentmedia.punjabinews, PID: 30473
      java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
          at android.content.ComponentName.&lt;init&gt;(ComponentName.java:130)
          at android.content.Intent.&lt;init&gt;(Intent.java:5780)
          at com.currentmedia.punjabinews.channeladpater$1.onItemClickListener(channeladpater.java:47)
          at com.currentmedia.punjabinews.channeladpater$Channelviewholder.onClick(channeladpater.java:75)
          at android.view.View.performClick(View.java:6294)
          at android.view.View$PerformClick.run(View.java:24770)
          at android.os.Handler.handleCallback(Handler.java:790)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6494)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
  2020-09-18 00:34:49.144 30473-30593/com.currentmedia.punjabinews E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
  2020-09-18 00:34:49.145 30473-30593/com.currentmedia.punjabinews E/EGL_emulation: tid 30593: swapBuffers(552): error 0x300d (EGL_BAD_SURFACE)
  </code></pre>
  <p>I cannot understand why it is giving null object reference when I added intent in MainActivity 2 as well</p>