java - Bundle getInt only return default value -


i have problem code return default value -1. tried debug, has value don't know why alway return -1.

private static final string key_category_id = "category"; bundle bundle = getarguments(); mcategoryid = bundle.getint(key_category_id, -1); 

this debug value:

bundle  bundle  (id=830037735464) bundle[{category=2}] 

in activity setarguments in way

mfragment = new myfragment(); bundle extras = this.getintent().getextras(); extras.putint("category", 10); mfragment.setarguments(extras); mfragmenttransaction = getsupportfragmentmanager().begintransaction(); mfragmenttransaction.add(r.id.profile_fragment, mfragment); mfragmenttransaction.commit(); 

in fragment in way

bundle bundle = getarguments(); catgory = bundle.getint("category"); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -