BlackBerry – how to mute incoming calls
I'm trying to mute incoming calls and prevent BlackBerry devices from ringing I tried alert SetVolume (0) and some eventinjector keys, but this does not work
So how to mute incoming calls?
Solution
I was puzzled by your question and decided to accept the challenge I've tried different things, including
>Play the "mute" audio file and want to overlap the ringing of the device or occupy the media player > through uiapplication Getuiapplication() hacker phone screen Getactivescreen() > inject keyboard events
Finally, injecting the volume up key (the volume down key also works normally) is useful for me and silences the device when an incoming call occurs The disadvantage of this method is that sometimes the device rings for a fraction of a second before silencing
import net.rim.blackBerry.api.phone.AbstractPhoneListener; import net.rim.blackBerry.api.phone.Phone; import net.rim.device.api.system.Application; import net.rim.device.api.system.EventInjector; import net.rim.device.api.ui.Keypad; class Muter extends AbstractPhoneListener { public void callIncoming(int callId) { Thread muterThread = new Thread(new Runnable() { public void run() { EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,(char) Keypad.KEY_VOLUME_UP,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP,0)); } }); muterThread.setPriority(Thread.MAX_PRIORITY); muterThread.start(); } } public class MuterApp extends Application { public static void main(String[] args){ Phone.addPhoneListener(new Muter()); new MyApp().enterEventDispatcher(); } }
The following is also valid (replace the muter thread in the callincoming () method with the following code)
UiApplication.getUiApplication().invokelater(new Runnable() { public void run() { EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,0)); } });