I\'m using a service. In that service my code should get executed when the user changes to silent mode, i.e. as soon as the user changes to silent mode, my code needs to get exe
You don't want use a service. Instead you want to use a BroadcastReciever that filters for the android.media.RINGER_MODE_CHANGED Intent.
You might want to take a look at this project as it deals with the phone being silenced. It probably has some source code that will be useful to you.