What I want:
I am developing one app where I want to display dialog / popup on incoming call.
I have observed in log that there is slight delay between my activity start on incoming call and phone screen getting on. First activity gets fired and then phone screen gets on.
So I want to display this dialog after the phone screen gets on. In short I want to wait till phone gets on.
What I Tried:
I have used Asynctask in BroadcastReceiver
protected Boolean doInBackground(Void... params) { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); isScreenOn = powerManager.isInteractive(); return isScreenOn; }
and followed this answer. But it is giving me compile time exception
unhandled exception java.util.concurrent.executionexception even after searching a lot on google I was not able to solve it. So I used another approach.
- I have created another* broadcast receiver for phone screen status as per this link
(*Note I already have incoming call broadcast receiver)
But I am not able to figure out how incoming call broadcast receiver will communicate to phone screen broadcast receiver and wait till phone screen gets on.
- I have even tried to add intent action in existing broadcast receiver but again dont know how to wait till phone screen gets on.
Any pointers/suggestions?