android - Values from the Intent is not showing -


i don't know did wrong on here. have followed tutorial values end being empty.

passsing values intent

listview lvitems = (listview) view.findviewbyid(r.id.lvdashboardcompleted);         lvitems.setonitemclicklistener(new adapterview.onitemclicklistener() {               @override             public void onitemclick(adapterview<?> parent, view view, int position, long id) {                 //toast shows id on here                 intent intent = new intent(getactivity(), categoryactivity.class);                 intent.putextra("category_id", id);                 startactivity(intent);             }         }); 

reviving value intent

public class categoryactivity extends appcompatactivity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         getsupportactionbar().hide();         setcontentview(r.layout.activity_category);          string recevied_cat_id = getintent().getstringextra("category_id");          context context = getapplicationcontext();         charsequence text = recevied_cat_id;         int duration = toast.length_short;          toast toast = toast.maketext(context, text, duration);         toast.show();     } } 

try replace oncreate method. issue? @arif has highlighted correctly, passing long intent in method retrieving string.

protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         getsupportactionbar().hide();         setcontentview(r.layout.activity_category);          long recevied_cat_id = getintent().getlongextra("category_id", 1l);          context context = getapplicationcontext();         string strlong = long.tostring(recevied_cat_id);         charsequence text = strlong;         int duration = toast.length_short;          toast toast = toast.maketext(context, text, duration);         toast.show();     } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -