/** * Beeps the device for a given number of times. By default, it will beep once. If the user * explicitly sets the beep count to zero, it will play the applications notification profile. The * application profile playback sequence is controlled by the user. * * @param args JSONArray formatted as [ count ] count: specifies the number of times to beep the * device (default: 1). * @return A CommandResult object with the success or failure state for beeping the device. */ public static PluginResult execute(JSONArray args) { PluginResult result = null; if (Alert.isAudioSupported()) { try { int repeatCount = 1; if (args.length() > 0 && !args.isNull(0)) { repeatCount = args.getInt(0); } // play tone n times if (repeatCount > 0) { playTone(repeatCount); } // FIXME: unsupported on other platforms // send notification event to application profile else { NotificationsManager.triggerImmediateEvent(PhoneGapExtension.getAppID(), 0, null, null); } } catch (JSONException e) { Logger.log(BeepAction.class.getName() + ": " + e); result = new PluginResult(PluginResult.Status.JSONEXCEPTION, e.getMessage()); } catch (Exception e) { Logger.log(BeepAction.class.getName() + ": " + e); result = new PluginResult(PluginResult.Status.IOEXCEPTION, e.getMessage()); } result = new PluginResult(PluginResult.Status.OK); } else { result = new PluginResult(PluginResult.Status.ILLEGALACCESSEXCEPTION, "Audio not supported"); } return result; }
/** * Entry point for application * * @param args Command line arguments (not used) */ public static void main(String[] args) { // Create a new instance of the application and make the currently // running thread the application's event dispatch thread. LinphoneMain theApp = new LinphoneMain(); NotificationsManager.registerSource( NOTIF_ID, new Object() { public String toString() { return Custom.APPNAME; } }, NotificationsConstants.IMPORTANT); theApp.enterEventDispatcher(); }