/** * ScreenOrientation property setter method: sets the screen orientation for the form. * * @param screenOrientation the screen orientation as a string */ @DesignerProperty( editorType = DesignerProperty.PROPERTY_TYPE_SCREEN_ORIENTATION, defaultValue = "unspecified") @SimpleProperty( category = PropertyCategory.APPEARANCE, description = "The requested screen orientation. Commonly used values are" + " \"unspecified\", \"landscape\", \"portrait\", \"sensor\", and \"behind\".") public void ScreenOrientation(String screenOrientation) { if (screenOrientation.equalsIgnoreCase("behind")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND); } else if (screenOrientation.equalsIgnoreCase("landscape")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (screenOrientation.equalsIgnoreCase("nosensor")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else if (screenOrientation.equalsIgnoreCase("portrait")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (screenOrientation.equalsIgnoreCase("sensor")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (screenOrientation.equalsIgnoreCase("unspecified")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else if (screenOrientation.equalsIgnoreCase("user")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } else if (SdkLevel.getLevel() >= SdkLevel.LEVEL_GINGERBREAD) { if (screenOrientation.equalsIgnoreCase("fullSensor")) { setRequestedOrientation(10); // ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR } else if (screenOrientation.equalsIgnoreCase("reverseLandscape")) { setRequestedOrientation(8); // ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE } else if (screenOrientation.equalsIgnoreCase("reversePortrait")) { setRequestedOrientation(9); // ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT } else if (screenOrientation.equalsIgnoreCase("sensorLandscape")) { setRequestedOrientation(6); // ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE } else if (screenOrientation.equalsIgnoreCase("sensorPortrait")) { setRequestedOrientation(7); // ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT } else { dispatchErrorOccurredEvent( this, "ScreenOrientation", ErrorMessages.ERROR_INVALID_SCREEN_ORIENTATION, screenOrientation); } } else { dispatchErrorOccurredEvent( this, "ScreenOrientation", ErrorMessages.ERROR_INVALID_SCREEN_ORIENTATION, screenOrientation); } }
protected void startNewForm(String nextFormName, String startupValue) { Intent activityIntent = new Intent(); // Note that the following is dependent on form generated class names being the same as // their form names and all forms being in the same package. activityIntent.setClassName(this, getPackageName() + "." + nextFormName); if (startupValue != null) { activityIntent.putExtra(ARGUMENT_NAME, startupValue); } // Save the nextFormName so that it can be passed to the OtherScreenClosed event in the // future. this.nextFormName = nextFormName; try { startActivityForResult(activityIntent, SWITCH_FORM_REQUEST_CODE); } catch (ActivityNotFoundException e) { String functionName = (startupValue == null) ? "open another screen" : "open another screen with start text"; dispatchErrorOccurredEvent( this, functionName, ErrorMessages.ERROR_SCREEN_NOT_FOUND, nextFormName); } }