I have 2 spinner
s in Blankfragment.java
and I want to send the key of intent.putExtra(Category1)
or intent.putExtra(Category2)
and receive them in the same activity aaa.java
by getIntent().getStringExtra("Category1")
; or getIntent().getStringExtra("Category2")
in switch case or if statement
but I cant do this because I can't use more than one getStringExtra
in aaa.java
please help me
Code of Blankfragment.java:
int spinner_pos = spinner.getSelectedItemPosition();
int spinner2_pos = spinner2.getSelectedItemPosition();
if (spinner_pos == 0 && spinner2_pos == 0) {
Intent intent = new Intent(getActivity(), aaa.class);
String a1 = null;
intent.putExtra("Category1", a1 );
startActivity(intent);
}
else if (spinner_pos == 0 && spinner2_pos == 1) {
Intent intent = new Intent(getActivity(), aaa.class);
String a2 = null;
intent.putExtra("Category2", a2);
startActivity(intent);
}
Code of aaa.java:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_aaa);
.
..
...
//need to use
getIntent().getStringExtra("Category1"); .. // for if -> "01"
and
getIntent().getStringExtra("Category2"); .. // for else if -> "02"
//in this if statment
if(// write something) {
loadListWorkers("01");
}
else if (//write something) {
loadListWorkers("02");
}
}
private void loadListWorkers(String placeId) {
adapter = new FirebaseRecyclerAdapter<workers, WorkerViewHolder>
( workers.class
, R.layout.vh_worker_item
, WorkerViewHolder.class
, workerList.orderByChild("Worker_place_ID").equalTo(placeId)
)
...
.....
.......
.........