Is there any workaround for this?
You have a lot more problems.
First, onReceive() is called in the main thread of the application, at the foreground priority. You cannot spend more than a few milliseconds without creating problems for the foreground application, for example, making you stutter in the game.
Secondly, you do not know what the user does when sending an SMS message. They can play the game. They may be in the middle of a phone call on their speakerphone. You cannot, you cannot, CANNOT decide unilaterally that you are going to communicate with a person through a text message. You can easily file a lawsuit and possibly worse.
I urge you to stop coding now, and lean back and think - really think - about what you are trying to do and the consequences of your approach.
source share