---
description: >-
  Events are Triggers which occurs when user open, close, press button, long
  click button, download completion etc.
---

# Events

## <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M577cQFqHqnBgupUQJQ%2Fic_cycle_color_48dp.png?alt=media&#x26;token=220ed305-3f88-4405-af63-807486a2d07e" alt="" data-size="line"> Activity

Source: [https://medium.com/sketchware/activity-lifecycle-in-android-applications-1b48a7bb584c](https://medium.com/sketchware/activity-lifecycle-in-android-applications-1b48a7bb584c)

![Activity Life-cycle (Pic. 9)](https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M579PaYWJwGOFDX76UT%2Factivity_life_cycle.png?alt=media\&token=34589e9f-6972-41b8-9556-40878b003379)

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onCreate

This is the event, when app is started. This is a good place to initialize any data such as variables or lists. In Sketchware, this event is provided by default.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onBackPressed

As the name suggests, the blocks in this event will run when back button is pressed from your phone.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onStart

This event occurs when you open/reopen the activity. See the Pic.9 for more details.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onPostCreate

This event is called when activity start-up or onStart is complete.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onResume

This event is called whenever the user returns to the activity after leaving the activity — such as receiving a call, pressing the home button, turning off the screen, or transitioning to another activity.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onPause

This event occurs when the user is leaving your activity.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onStop

When your activity is no longer visible to the user. This is usually a good point to pause any ongoing process, such as MediaPlayer or SoundPool.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57ANEpqivIvTkxfou2%2Fwidget_source.png?alt=media&#x26;token=db132f6e-ce75-4d5f-a22b-5fed0d6fa8a1" alt="" data-size="line"> onDestroy

When the activity is closed, this will last event of Activity. It also occurs when somebody close the app correctly. (Force close can be exception)

## <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57E4BIzR4qP4xzIAqs%2Fmultiple_devices_48.png?alt=media&#x26;token=6e54edde-2a0e-4399-8e72-5152f99b0760" alt="" data-size="line"> View

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57F0zpK981lh_1dKf9%2Fevent_on_click_48dp.png?alt=media&#x26;token=5eaf8e56-0ae6-46b5-85bc-b12e37cca469" alt="" data-size="line"> onClick

A simple Event when that specific widget is clicked.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M3EmlQGfOfyVOYtEnjw%2F-M3EpnBKB15OG_P4kSZB%2Fevent_on_text_changed_48dp.png?alt=media&#x26;token=3c048e10-251c-427a-bcaf-ccf924a9cb03" alt="" data-size="line"> onTextChanged

Whenever the text in 'edittext' is changed.

{% hint style="success" %}
**onTextChanged** also occurs when you set text by using blocks
{% endhint %}

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M56xBG3b3LqOTjTJybR%2F-M57JvCpEPXCd04XMN6K%2Fevent_on_check_changed_48dp.png?alt=media&#x26;token=b188c52b-5eea-4f70-a391-ccc83857a998" alt="" data-size="line"> onCheckChanged

This event occurs when the value of Checkbox/Switch is changed.

{% hint style="success" %}
**onCheckChanged** also occurs when you change check by using blocks
{% endhint %}

![An Example (Pic. 10)](https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M57Lx38ojyLlQdBoV0p%2F-M57MHGPjzfdOajt_89t%2Fcheck_uncheck.jpg?alt=media\&token=b65ba456-17a3-4839-9c9f-7ab69beb4690)

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M57Lx38ojyLlQdBoV0p%2F-M57PYgc8mAHICA3sudq%2Fevent_on_progress_changed_48dp.png?alt=media&#x26;token=368eaf6d-687b-402c-8883-ccf5c92b1787" alt="" data-size="line"> onProgressChanged&#x20;

This event occurs when progress is changed for seekbar. (Only for Seekbar)

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M57Lx38ojyLlQdBoV0p%2F-M57PoZ9JcVuwXJcrxWN%2Fevent_on_start_tracking_touch_48dp.png?alt=media&#x26;token=105d41c0-cd45-4a51-bd98-f9ee35926479" alt="" data-size="line"> onStartTrackingTouch

This event occurs when the user holds the seekbar to change it. (Only for Seekbar)

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M57Lx38ojyLlQdBoV0p%2F-M57Q2l0d-920SPc8n9p%2Fevent_on_stop_tracking_touch_48dp.png?alt=media&#x26;token=e523ab51-71e7-4f6c-968f-9a89f666d33c" alt="" data-size="line"> onStopTrackingTouch

This event occurs when the user stop holding the seekbar when he is done. (Only for Seekbar)

MAPVIEW will be added soon.

### <img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-M57Lx38ojyLlQdBoV0p%2F-M57QojFNqoNzwQeKesf%2Fevent_on_date_changed_48dp.png?alt=media&#x26;token=6deac1cd-9fd5-44d1-91f1-e6b505be5d59" alt="" data-size="line"> onDateChange

This event occurs when the user selects a date in a CalendarView. (Only for CalendarView)
