android - How to implement Firebase Cloud messaging with Foreground application? -
how receive message in activity application in foreground , display message toast? receive notification when app in background.
something messages in real time.
please me !!
on oncreate method of activity display toast.write.
registerreceiver(new myreceiver(),new intentfilter("myreceiver"));
then create myreceiver broadcastreceiver inner class in activity. as.
public class myreceiver extends broadcastreceiver{ public void onreceive(context context, intent intent){ toast.maketext(context,intent.getstringextra("from")+" "+intent.getstringextra("message"),toast.length_short).show(); } } ///finally have write following codes on onmessagereceived intent intents=new intent(); intents.setaction("myreceiver"); intents.putextra("message",message.getdata().get("message")); intents.putextra("from",message.getdata().get("from")); getbasecontext().sendbroadcast(intents);
Comments
Post a Comment