title: when Pressed Back Button on RecyclerView it takes to the Home Screen
body: <p>I have created a Horizontal <code>RecyclerView</code>, It has <code>onClickListener</code>, When User Clicks on it, It opens <code>Video Player</code>. The Problems arises when user clicks on Back Button.</p>
  
  <p>When user clicks on Back Button it takes user to the <code>MainActivity</code> and not to the original activity from where user actually launches the Video.</p>
  
  <p>This is what i have done. Kindly guide me how to keep the History of previous activity when opening another activity from <code>recyclerView onClickListener</code></p>
  
  <p><strong>ListActivity</strong></p>
  
  <pre><code> VideosRecyclerView recyclerAdapter = new VideosRecyclerView(this, videosList);
          LinearLayoutManager layoutManager
                  = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
  
          lvRecyclerVideosList.setLayoutManager(layoutManager);
          lvRecyclerVideosList.setItemAnimator(new DefaultItemAnimator());
          lvRecyclerVideosList.setAdapter(recyclerAdapter);
  </code></pre>
  
  <p><strong>RecyclerAdapter</strong></p>
  
  <pre><code>public class VideosRecyclerView extends RecyclerView.Adapter&lt;VideosRecyclerView.ViewHolder&gt; {
  
      public VideosRecyclerView(Context context, ArrayList&lt;VideosService&gt; dataList){
          this.context= context;
          this.dataList= dataList;
      }
  
   @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_video_list, parent, false);
          return new ViewHolder(v, context, dataList);
      }
  
  
   @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          VideosService item = dataList.get(position);
  
          holder.textView.setText(item.getTitle());
          videoURL= item.getVideoURL();
  
      }
  
  
   public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
          public ImageView imageView;
          Context context;
  
       @Override
          public void onClick(View v) {
              int position= getAdapterPosition();
              VideosService videosService= this.dataList.get(position);
              Intent i= new Intent(context, VideoActivity.class);
              i.putExtra("videoURL", videosService.getVideoURL());
              context.startActivity(i);
  
          }
  </code></pre>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>   &lt;activity
          android:name=".gdvl.VideoLists
          android:label="@string/app_name"
          android:screenOrientation="portrait"
          android:theme="@style/AppTheme.NoActionBar" /&gt;
  
      &lt;activity
          android:name=".VideoActivity"
          android:configChanges="orientation|screenSize"
          android:label="@string/title_activity_video"
          android:theme="@style/AppTheme" /&gt;
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>This is how i start VideoList</p>
  
  <pre><code>                Intent i = new Intent(gdData.this, videoLists.class);
                  i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                  finish();
                  startActivity(i);
  </code></pre>
  
  <p>I removed the History of the activity that starts <code>videoLists</code>, but i never removed History of <code>VideoLists</code>. This is how is start VideoPlayer</p>
  
  <pre><code> Intent i= new Intent(context, VideoActivity.class);
              i.putExtra("videoURL", videosService.getVideoURL());
              context.startActivity(i);
  </code></pre>