title: Calling startActivity() outside of an Activity context requires FLAG_ACTIVITY_NEW_TASK
body: <p>I am getting the error <code>AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag</code>. The full stack trace:</p>
  <pre><code>main Process: com.kd.book, PID: 3487 android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ContextImpl.startActivity(ContextImpl.java:1238) at android.app.ContextImpl.startActivity(ContextImpl.java:1225) at com.kd.book.Adapter.MyComicAdapter$1.onClick(MyComicAdapter.java:63) at com.kd.book.Adapter.MyComicAdapter$MyViewHolder.onClick(MyComicAdapter.java:99)
  </code></pre>
  <p>I am new to Android development and do not know how to solve it.</p>
  <p>My Code:</p>
  <pre><code>public class MyComicAdapter extends RecyclerView.Adapter&lt;MyComicAdapter.MyViewHolder&gt; {
      Context context;
      List&lt;Comic&gt; comicList;
      LayoutInflater inflater;
  
      public MyComicAdapter(Context context, List&lt;Comic&gt; comicList) {
          this.context = context;
          this.comicList = comicList;
          inflater=LayoutInflater.from(context);
      }
  
      @NonNull
      @Override
      public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
  
          View itemView = inflater.inflate(R.layout.comic_item, viewGroup, false);
          return new MyViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, final int i) {
  
          Picasso.get().load(comicList.get(i).Image).into(myViewHolder.comic_image);
          myViewHolder.comic_name.setText(comicList.get(i).Name);
  
          //Event
  
          myViewHolder.setRecyclerItemClickListener(new IRecyclerItemClickListener(){
  
              @Override
              public void onClick(View view, int position) {
                  //save the comic selected
                  Common.comicSelected = comicList.get(position);
                  Intent intent = new Intent(Intent.ACTION_VIEW);
                  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  context.startActivity(new Intent(context,ChapterActivity.class));
  
              }
          });
      }
  
      @Override
      public int getItemCount() {
          return comicList.size();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
          TextView comic_name;
          ImageView comic_image;
  
          IRecyclerItemClickListener recyclerItemClickListener;
  
          public void setRecyclerItemClickListener(IRecyclerItemClickListener recyclerItemClickListener) {
              this.recyclerItemClickListener = recyclerItemClickListener;
          }
  
          public MyViewHolder(@NonNull View itemView) {
              super(itemView);
  
              comic_image = itemView.findViewById(R.id.image_comic);
              comic_name = itemView.findViewById(R.id.comic_name);
  
              itemView.setOnClickListener(this);
          }
  
          @Override
          public void onClick(View view) {
  
              recyclerItemClickListener.onClick(view, getAdapterPosition());
          }
      }
  }
  </code></pre>
  <p>Any ideas?</p>