Currently I have an ArrayList that I wanted to pass to another activity. I've already applied getParcelableArrayList
but it pass null to another activity. I've check the array for null, it's not. In the current activity before I pass it at least.
This is my code:
RecyclerViewOffline.java
Toast.makeText(context,"Clicked", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(view.getContext(),OfflineActivity.class);
Log.d("Contexts Test : ", fileContents.get(holder.getLayoutPosition()).getTitle());
Bundle bundle = new Bundle();
//bundle.putParcelableArrayList("link",fileContents);
bundle.putParcelableArrayList("ArrayList",fileContents);
bundle.putInt("position",holder.getLayoutPosition());
intent.putExtra("bundle",bundle);
view.getContext().startActivity(intent);
My receiving end:
OfflineActivity.java
Bundle extras = getIntent().getBundleExtra("bundle");
if(extras != null) {
this.fileContents = extras.getParcelableArrayList("ArrayList");
layoutPosition = extras.getInt("position");
Log.d("Contexts Test Offline: ",""+ fileContents.get(layoutPosition).getTitle());
}
else{}