public class Form extends android.app.Activity implements Component, ComponentContainer, HandlesEventDispatching
This is the root container of any Android activity and also the superclass for for Simple/Android UI applications. The main form is always named "Screen1".
| Modifier and Type | Field and Description |
|---|---|
protected static Form |
activeForm |
static java.lang.String |
APPINVENTOR_URL_SCHEME |
protected java.lang.String |
formName |
protected java.lang.String |
startupValue |
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OKACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICEACCELEROMETER_SENSITIVITY_MODERATE, ACCELEROMETER_SENSITIVITY_STRONG, ACCELEROMETER_SENSITIVITY_WEAK, ALIGNMENT_CENTER, ALIGNMENT_NORMAL, ALIGNMENT_OPPOSITE, ASSET_DIRECTORY, BUTTON_SHAPE_DEFAULT, BUTTON_SHAPE_OVAL, BUTTON_SHAPE_RECT, BUTTON_SHAPE_ROUNDED, COLOR_BLACK, COLOR_BLUE, COLOR_CYAN, COLOR_DEFAULT, COLOR_DKGRAY, COLOR_GRAY, COLOR_GREEN, COLOR_LTGRAY, COLOR_MAGENTA, COLOR_NONE, COLOR_ORANGE, COLOR_PINK, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, DEFAULT_VALUE_COLOR_BLACK, DEFAULT_VALUE_COLOR_BLUE, DEFAULT_VALUE_COLOR_CYAN, DEFAULT_VALUE_COLOR_DEFAULT, DEFAULT_VALUE_COLOR_DKGRAY, DEFAULT_VALUE_COLOR_GRAY, DEFAULT_VALUE_COLOR_GREEN, DEFAULT_VALUE_COLOR_LTGRAY, DEFAULT_VALUE_COLOR_MAGENTA, DEFAULT_VALUE_COLOR_NONE, DEFAULT_VALUE_COLOR_ORANGE, DEFAULT_VALUE_COLOR_PINK, DEFAULT_VALUE_COLOR_RED, DEFAULT_VALUE_COLOR_WHITE, DEFAULT_VALUE_COLOR_YELLOW, DIRECTION_EAST, DIRECTION_MAX, DIRECTION_MIN, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_NORTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, FONT_DEFAULT_SIZE, LAYOUT_ORIENTATION_HORIZONTAL, LAYOUT_ORIENTATION_VERTICAL, LENGTH_FILL_PARENT, LENGTH_PREFERRED, LENGTH_UNKNOWN, SLIDER_MAX_VALUE, SLIDER_MIN_VALUE, SLIDER_THUMB_VALUE, TOAST_LENGTH_LONG, TOAST_LENGTH_SHORT, TYPEFACE_DEFAULT, TYPEFACE_MONOSPACE, TYPEFACE_SANSSERIF, TYPEFACE_SERIF| Constructor and Description |
|---|
Form() |
| Modifier and Type | Method and Description |
|---|---|
void |
$add(AndroidViewComponent component)
Adds a component to a container.
|
android.app.Activity |
$context()
Returns the activity context (which can be retrieved from the root
container - aka the form).
|
protected void |
$define()
Compiler-generated method to initialize and add application components to
the form.
|
Form |
$form()
Returns the form that ultimately contains this container.
|
java.lang.String |
AboutScreen()
AboutScreen property getter method.
|
void |
AboutScreen(java.lang.String aboutScreen)
AboutScreen property setter method: sets a new aboutApp string for the form in the
form's "About this application" menu.
|
void |
addAboutInfoToMenu(android.view.Menu menu) |
void |
addExitButtonToMenu(android.view.Menu menu) |
int |
AlignHorizontal()
Returns a number that encodes how contents of the screen are aligned horizontally.
|
void |
AlignHorizontal(int alignment)
Sets the horizontal alignment for contents of the screen
|
int |
AlignVertical()
Returns a number that encodes how contents of the arrangement are aligned vertically.
|
void |
AlignVertical(int alignment)
Sets the vertical alignment for contents of the screen
|
void |
AppName(java.lang.String aName)
Specifies the App Name.
|
int |
BackgroundColor()
BackgroundColor property getter method.
|
void |
BackgroundColor(int argb)
BackgroundColor property setter method.
|
java.lang.String |
BackgroundImage()
Returns the path of the background image.
|
void |
BackgroundImage(java.lang.String path)
Specifies the path of the background image.
|
boolean |
BackPressed() |
void |
callInitialize(java.lang.Object component) |
boolean |
canDispatchEvent(Component component,
java.lang.String eventName) |
void |
clear() |
protected void |
closeApplicationFromBlocks() |
protected void |
closeForm(android.content.Intent resultIntent) |
java.lang.String |
CloseScreenAnimation()
Returns the type of close screen animation (default, fade, zoom, slidehorizontal,
slidevertical and none).
|
void |
CloseScreenAnimation(java.lang.String animType)
Sets the animation type for the transition of this form closing and returning
to a form behind it in the activity stack.
|
void |
deleteComponent(java.lang.Object component) |
void |
dispatchErrorOccurredEvent(Component component,
java.lang.String functionName,
int errorNumber,
java.lang.Object... messageArgs) |
void |
dispatchErrorOccurredEventDialog(Component component,
java.lang.String functionName,
int errorNumber,
java.lang.Object... messageArgs) |
boolean |
dispatchEvent(Component component,
java.lang.String componentName,
java.lang.String eventName,
java.lang.Object[] args)
A trivial implementation to artificially make this class concrete so
that it is included in the documentation and
Codeblocks language definition file generated by
com.google.appinventor.components.scripts.DocumentationGenerator and
com.google.appinventor.components.scripts.LangDefXmlGenerator,
respectively. |
void |
dontGrabTouchEventsForComponent() |
void |
ErrorOccurred(Component component,
java.lang.String functionName,
int errorNumber,
java.lang.String message)
ErrorOccurred event handler.
|
void |
ErrorOccurredDialog(Component component,
java.lang.String functionName,
int errorNumber,
java.lang.String message,
java.lang.String title,
java.lang.String buttonText) |
static void |
finishActivity()
Closes the current screen, as opposed to finishApplication, which
exits the entire application.
|
static void |
finishActivityWithResult(java.lang.Object result) |
static void |
finishActivityWithTextResult(java.lang.String result) |
static void |
finishApplication() |
android.os.Bundle |
fullScreenVideoAction(int action,
VideoPlayer source,
java.lang.Object data)
Perform some action related to fullscreen video display.
|
static Form |
getActiveForm() |
HandlesEventDispatching |
getDispatchDelegate()
Returns the dispatch delegate that is responsible for dispatching events
for this component.
|
java.lang.String |
getOpenAnimType() |
static java.lang.String |
getStartText()
Returns the string that was passed to this screen when it was opened
|
static java.lang.Object |
getStartValue()
Returns the value that was passed to this screen when it was opened
|
int |
Height()
Height property getter method.
|
void |
Icon(java.lang.String name)
Specifies the name of the application icon.
|
void |
Initialize()
Initialize event handler.
|
protected static java.lang.String |
jsonEncodeForForm(java.lang.Object value,
java.lang.String functionName) |
protected void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent data) |
void |
onConfigurationChanged(android.content.res.Configuration newConfig) |
void |
onCreate(android.os.Bundle icicle) |
android.app.Dialog |
onCreateDialog(int id) |
boolean |
onCreateOptionsMenu(android.view.Menu menu) |
protected void |
onDestroy() |
boolean |
onKeyDown(int keyCode,
android.view.KeyEvent event) |
protected void |
onNewIntent(android.content.Intent intent) |
protected void |
onPause() |
void |
onPrepareDialog(int id,
android.app.Dialog dialog) |
protected void |
onResume() |
protected void |
onStop() |
java.lang.String |
OpenScreenAnimation()
Returns the type of open screen animation (default, fade, zoom, slidehorizontal,
slidevertical and none).
|
void |
OpenScreenAnimation(java.lang.String animType)
Sets the animation type for the transition to another screen.
|
void |
OtherScreenClosed(java.lang.String otherScreenName,
java.lang.Object result) |
int |
registerForActivityResult(ActivityResultListener listener) |
void |
registerForOnDestroy(OnDestroyListener component) |
void |
registerForOnInitialize(OnInitializeListener component)
An app can register to be notified when App Inventor's Initialize
block has fired.
|
void |
registerForOnNewIntent(OnNewIntentListener component) |
void |
registerForOnPause(OnPauseListener component) |
void |
registerForOnResume(OnResumeListener component) |
void |
registerForOnStop(OnStopListener component) |
java.lang.String |
ScreenOrientation()
The requested screen orientation.
|
void |
ScreenOrientation(java.lang.String screenOrientation)
ScreenOrientation property setter method: sets the screen orientation for
the form.
|
void |
ScreenOrientationChanged() |
boolean |
Scrollable()
Scrollable property getter method.
|
void |
Scrollable(boolean scrollable)
Scrollable property setter method.
|
void |
setChildHeight(AndroidViewComponent component,
int height) |
void |
setChildWidth(AndroidViewComponent component,
int width) |
protected void |
startNewForm(java.lang.String nextFormName,
java.lang.Object startupValue) |
static void |
switchForm(java.lang.String nextFormName)
Display a new form.
|
static void |
switchFormWithStartValue(java.lang.String nextFormName,
java.lang.Object startValue)
Display a new form and pass a startup value to the new form.
|
java.lang.String |
Title()
Title property getter method.
|
void |
Title(java.lang.String title)
Title property setter method: sets a new caption for the form in the
form's title bar.
|
protected boolean |
toastAllowed() |
void |
unregisterForActivityResult(ActivityResultListener listener) |
void |
VersionCode(int vCode)
Specifies the Version Code.
|
void |
VersionName(java.lang.String vName)
Specifies the Version Name.
|
int |
Width()
Width property getter method.
|
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateNavigateUpTaskStack, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenuapplyOverrideConfiguration, attachBaseContext, getResources, getTheme, setThemebindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiverpublic static final java.lang.String APPINVENTOR_URL_SCHEME
protected static Form activeForm
protected java.lang.String formName
protected java.lang.String startupValue
public void onCreate(android.os.Bundle icicle)
onCreate in class android.app.Activitypublic void onConfigurationChanged(android.content.res.Configuration newConfig)
onConfigurationChanged in interface android.content.ComponentCallbacksonConfigurationChanged in class android.app.Activitypublic boolean onKeyDown(int keyCode,
android.view.KeyEvent event)
onKeyDown in interface android.view.KeyEvent.CallbackonKeyDown in class android.app.Activitypublic boolean BackPressed()
protected void onActivityResult(int requestCode,
int resultCode,
android.content.Intent data)
onActivityResult in class android.app.Activitypublic int registerForActivityResult(ActivityResultListener listener)
public void unregisterForActivityResult(ActivityResultListener listener)
protected void onResume()
onResume in class android.app.Activitypublic void registerForOnResume(OnResumeListener component)
public void registerForOnInitialize(OnInitializeListener component)
component - protected void onNewIntent(android.content.Intent intent)
onNewIntent in class android.app.Activitypublic void registerForOnNewIntent(OnNewIntentListener component)
protected void onPause()
onPause in class android.app.Activitypublic void registerForOnPause(OnPauseListener component)
protected void onStop()
onStop in class android.app.Activitypublic void registerForOnStop(OnStopListener component)
protected void onDestroy()
onDestroy in class android.app.Activitypublic void registerForOnDestroy(OnDestroyListener component)
public android.app.Dialog onCreateDialog(int id)
onCreateDialog in class android.app.Activitypublic void onPrepareDialog(int id,
android.app.Dialog dialog)
onPrepareDialog in class android.app.Activityprotected void $define()
com.google.appinventor.components.scripts.DocumentationGenerator and
com.google.appinventor.components.scripts.LangDefXmlGenerator,
respectively. The actual implementation appears in runtime.scm.public boolean canDispatchEvent(Component component, java.lang.String eventName)
canDispatchEvent in interface HandlesEventDispatchingpublic boolean dispatchEvent(Component component, java.lang.String componentName, java.lang.String eventName, java.lang.Object[] args)
com.google.appinventor.components.scripts.DocumentationGenerator and
com.google.appinventor.components.scripts.LangDefXmlGenerator,
respectively. The actual implementation appears in runtime.scm.dispatchEvent in interface HandlesEventDispatchingpublic void Initialize()
public void ScreenOrientationChanged()
public void ErrorOccurred(Component component, java.lang.String functionName, int errorNumber, java.lang.String message)
public void ErrorOccurredDialog(Component component, java.lang.String functionName, int errorNumber, java.lang.String message, java.lang.String title, java.lang.String buttonText)
public void dispatchErrorOccurredEvent(Component component, java.lang.String functionName, int errorNumber, java.lang.Object... messageArgs)
public void dispatchErrorOccurredEventDialog(Component component, java.lang.String functionName, int errorNumber, java.lang.Object... messageArgs)
public boolean Scrollable()
public void Scrollable(boolean scrollable)
scrollable - true if the screen should be vertically scrollablepublic int BackgroundColor()
public void BackgroundColor(int argb)
argb - background RGB color with alphapublic java.lang.String BackgroundImage()
public void BackgroundImage(java.lang.String path)
MediaUtil.determineMediaSource(com.google.appinventor.components.runtime.Form, java.lang.String) for information about what
a path can be.path - the path of the background imagepublic java.lang.String Title()
public void Title(java.lang.String title)
title - new form captionpublic java.lang.String AboutScreen()
public void AboutScreen(java.lang.String aboutScreen)
title - new form captionpublic java.lang.String ScreenOrientation()
public void ScreenOrientation(java.lang.String screenOrientation)
screenOrientation - the screen orientation as a stringpublic int AlignHorizontal()
public void AlignHorizontal(int alignment)
alignment - public int AlignVertical()
public void AlignVertical(int alignment)
alignment - public java.lang.String OpenScreenAnimation()
public void OpenScreenAnimation(java.lang.String animType)
animType - the type of animation to use for the transitionpublic java.lang.String CloseScreenAnimation()
public void CloseScreenAnimation(java.lang.String animType)
animType - the type of animation to use for the transitionpublic java.lang.String getOpenAnimType()
public void Icon(java.lang.String name)
name - the name of the application iconpublic void VersionCode(int vCode)
vCode - the version name of the applicationpublic void VersionName(java.lang.String vName)
vName - the version name of the applicationpublic void AppName(java.lang.String aName)
aName - the display name of the installed application in the phonepublic int Width()
public int Height()
public static void switchForm(java.lang.String nextFormName)
nextFormName - the name of the new form to displaypublic static void switchFormWithStartValue(java.lang.String nextFormName,
java.lang.Object startValue)
nextFormName - the name of the new form to displaystartValue - the start value to pass to the new formprotected void startNewForm(java.lang.String nextFormName,
java.lang.Object startupValue)
protected static java.lang.String jsonEncodeForForm(java.lang.Object value,
java.lang.String functionName)
public void OtherScreenClosed(java.lang.String otherScreenName,
java.lang.Object result)
public HandlesEventDispatching getDispatchDelegate()
ComponentgetDispatchDelegate in interface Componentpublic android.app.Activity $context()
ComponentContainer$context in interface ComponentContainerpublic Form $form()
ComponentContainer$form in interface ComponentContainerpublic void $add(AndroidViewComponent component)
ComponentContainer$add in interface ComponentContainercomponent - component associated with viewpublic void setChildWidth(AndroidViewComponent component, int width)
setChildWidth in interface ComponentContainerpublic void setChildHeight(AndroidViewComponent component, int height)
setChildHeight in interface ComponentContainerpublic static Form getActiveForm()
public static java.lang.String getStartText()
public static java.lang.Object getStartValue()
public static void finishActivity()
public static void finishActivityWithResult(java.lang.Object result)
public static void finishActivityWithTextResult(java.lang.String result)
protected void closeForm(android.content.Intent resultIntent)
public static void finishApplication()
protected void closeApplicationFromBlocks()
public boolean onCreateOptionsMenu(android.view.Menu menu)
onCreateOptionsMenu in class android.app.Activitypublic void addExitButtonToMenu(android.view.Menu menu)
public void addAboutInfoToMenu(android.view.Menu menu)
public void clear()
public void deleteComponent(java.lang.Object component)
public void dontGrabTouchEventsForComponent()
protected boolean toastAllowed()
public void callInitialize(java.lang.Object component)
throws java.lang.Throwable
java.lang.Throwablepublic android.os.Bundle fullScreenVideoAction(int action,
VideoPlayer source,
java.lang.Object data)
action - Can be any of the following:
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_DURATION
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_FULLSCREEN
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_PAUSE
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_PLAY
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_SEEK
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_SOURCE
FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_STOP
source - The VideoPlayer to use in some actions.data - Used by the method. This object varies depending on the action.