I have Activity
> Fragment
> RecyclerView
.
I am getting data from server in a ArrayList
to inflate recyclerView
in onCreate()
of fragment.
In recyclerView
there is Image
with which I open camera and click photo.
But when I return after successful image capture, I get my ArrayList
null
onCreate
in ShipmentFragment
:
ArrayList<ShipmentDetails> shipmentList;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
shipmentList = getShipmentLists();
}
in activity's onActivityResult
:
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CAMERA_IMAGE_CAPTURE_REQUEST_CODE:
if (resultCode == RESULT_OK) {
ShipmentFragment shipmentFragment = new ShipmentFragment();
shipmentFragment.entryToList();
} else {
Toast.makeText(OrderActivity.this, "Error capturing image", Toast.LENGTH_SHORT).show();
}
break;
}
entryToList()
in ShipmentFragment
:
public void entryToList() {
// Here I get shipmentList null
int size = shipmentList.size();
}