android - Why this code does not make a notification in BroadcastReceiver -


i want make notification broadcastreceiver. i'm using code in activity , works fine can't make notification broadcastreceiver . me solve problem :

random rd;rd= new random ();             notificationmanager notificationmanager = (notificationmanager) ctx.getsystemservice(context.notification_service);             intent notificationintent = new intent(intent.action_view);             notificationintent.setdata(uri.parse(link));             pendingintent pending=null;             pending = pendingintent.getactivity(ctx, 0, notificationintent, pending.flag_update_current);              notification mynotification = new notificationcompat.builder(ctx)                     .setsmallicon(r.drawable.ic_launcher).setautocancel(false).setlargeicon(remote_picture)                     .setcontenttitle(onvan).setstyle(new notificationcompat.bigtextstyle().bigtext(msg))                     .setcontenttext(msg).setcontentintent(pending).build();             notificationmanager.notify(rd.nextint(75), mynotification); 

the problem , code not make notification , no notification showing in tray .as , run code in activity , works find in broadcastreceiver not make notifications

to execute code inside broadcastreceiver have call sendbroadcast() method or set action in manifest file like

<receiver android:name="your package name.receivername">   <intent-filter>       <action android:name="android.intent.action.boot_completed" />     //set action here   </intent-filter>   </receiver> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -