0

I have an android application. I have a background service running on a worker thread. My app is in background (home key pressed). Some message came to the service worker thread. Now i want to show the content of this message on dialog . Since my app is in background ,what context should i use to show this dialog. I mean this dialog should be shown on any screen , may be some other app's screen .Because my app is in background and user might be using some other app , and meanwhile the message came to service thread. So it should be shown on the top of the other application

Pardeep Kumar
  • 900
  • 1
  • 14
  • 30
  • You will need `app Overlay` permission from user to get your dialog shown. – Mustansir Dec 12 '17 at 03:51
  • Push notifications are designed for this one. No need to reinvent the wheel. Users will dislike your app, if some unwanted dialogs will appear during app is in background. – Northern Poet Dec 12 '17 at 04:06
  • Use WidowManager and create an overlay and add your view in that. Use this URL for reference https://gist.github.com/bjoernQ/6975256 and as Michal_196 says you need app overlay permission for that – RajatN Dec 12 '17 at 04:11
  • you need to create a dialog theme activity and from your service you can call your dialog themed activity from where you will have context of that activity. – yashkal Dec 12 '17 at 04:25
  • @NorthernPoet my app is for offline messaging , i do not use push notifications. – Pardeep Kumar Dec 12 '17 at 05:05
  • @PardeepKumar, general notifications is fine, https://developer.android.com/guide/topics/ui/notifiers/notifications.html?hl=en – Northern Poet Dec 12 '17 at 05:07
  • @ Pradeep please have a look at this [answer](https://stackoverflow.com/a/39691342/5308778) – yashkal Dec 12 '17 at 06:05

0 Answers0