Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PendingIntent getBroadcast and getActivity at same Time

I want to implement pendingIntent.getbroadcast and pendingIntent.getactivity at same time. Actually my application is sending the notification When user Click on my notification my Application will start(by using getActivity) and It also broadcast to my broadcast receiver to perform some activity by my broad cast receiver. Thanks in advance

like image 344
malik M Avatar asked Nov 03 '22 12:11

malik M


1 Answers

You can either:

  • Use a getBroadcast() PendingIntent and have the BroadcastReceiver call startActivity() to start the activity, or

  • Use a getActivity() PendingIntent and have the Activity call sendBroadcast() to send the broadcast

If the activity will be used for things other than this Notification, the first solution is probably easier to implement.

like image 114
CommonsWare Avatar answered Nov 12 '22 16:11

CommonsWare