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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -