java - Can't write in inflate layout -
i'm using broadcastreceiver in draweractivity in can receive notification service , set text of notification in layout in fragment (the first fragment of navigation drawer). draweractivity start broadcastreceiver (i tried start directly fragment doesn't work!) broadcastreceiver:
public broadcastreceiver onnotice= new broadcastreceiver() { linearlayout notificationlayout; drawable icon; @override public void onreceive(context context, intent intent) { final string pack = intent.getstringextra("package"); string title = intent.getstringextra("title"); string text = intent.getstringextra("text"); view myview = getlayoutinflater().inflate(r.layout.activity_main, null); notificationlayout = (linearlayout)myview.findviewbyid(r.id.notificationlayout); textview notificationdescription = (textview) myview.findviewbyid(r.id.notificationdesc); textview notificationtitle = (textview) myview.findviewbyid(r.id.notificationtitle); circularimageview notificationimage = (circularimageview) myview.findviewbyid(r.id.img_thumbnail); log.i("notification ", title); toast.maketext(draweractivity.this, title, toast.length_short).show(); if(!pack.equals("") || !title.equals("") || !text.equals("")) { notificationlayout.setvisibility(view.visible); notificationtitle.settext("ciao"); notificationdescription.settext(text); try { icon = draweractivity.this.getpackagemanager().getapplicationicon(pack); } catch (packagemanager.namenotfoundexception e) { e.printstacktrace(); } notificationimage.setimagedrawable(icon); notificationlayout.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { try { packagemanager pmi = draweractivity.this.getpackagemanager(); intent intent; intent = pmi.getlaunchintentforpackage(pack); if (intent != null) { draweractivity.this.startactivity(intent); } //localbroadcastmanager.getinstance(mainactivity.instance).sendbroadcast(new intent("collapseafterclick")); } catch (exception ignored) { } } }); notificationlayout.setonlongclicklistener(new view.onlongclicklistener() { @override public boolean onlongclick(view view) { notificationlayout.setvisibility(view.invisible); return true; } }); } else { notificationlayout.setvisibility(view.invisible); } } };
in way it's strange!!! when notification arrives toast inside broadcastrecevier fired settext in inflate layout not! can see notification toast not in layout! how possible?
the issue code doesnt enter if statement.
*if(!pack.equals("") || !title.equals("") || !text.equals(""))*
Comments
Post a Comment