I’m trying to send 2 parameter from one activity to another,but for some reason only one of the parameter is passed. what could it be?
Sending Activity:
showActivity(OrderActivity.class, new Pair("CUSTOMER_ID", customerId), new Pair("CUSTOMER_TYPE", customerType));
Receiving Activity : The customer id is showing 0 but the type data is got
Bundle extras = getIntent().getExtras();
long customerId = extras.getLong("CUSTOMER_ID");
int customerType = extras.getInt("CUSTOMER_TYPE");
Log.d("===customer ", " id : " + customerId + " type : " + customerType);
the showActivity looks like this
protected void showActivity(Class<? extends BaseKaizenActivity> clazz, Pair<String, Object> ... parameters) {
Intent intent = new Intent(this, clazz);
if (parameters != null) {
for (Pair<String, Object> pair : parameters) {
if (pair.second instanceof Integer) {
intent.putExtra(pair.first, (Integer)pair.second);
}
else if (pair.second instanceof Parcelable) {
intent.putExtra(pair.first, (Parcelable)pair.second);
}
}
}
startActivity(intent);
}
Seems like you fogot to write a clause for Long.It gose neither of if nor else if,so has not been put into extradata.