# Events

## <img src="/files/-M577cQFqHqnBgupUQJQ" alt="" data-size="line"> Activity

Source: <https://medium.com/sketchware/activity-lifecycle-in-android-applications-1b48a7bb584c>

![Activity Life-cycle (Pic. 9)](/files/-M579PaYWJwGOFDX76UT)

### <img src="/files/-M57ANEpqivIvTkxfou2" 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="/files/-M57ANEpqivIvTkxfou2" 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="/files/-M57ANEpqivIvTkxfou2" alt="" data-size="line"> onStart

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

### <img src="/files/-M57ANEpqivIvTkxfou2" alt="" data-size="line"> onPostCreate

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

### <img src="/files/-M57ANEpqivIvTkxfou2" 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="/files/-M57ANEpqivIvTkxfou2" alt="" data-size="line"> onPause

This event occurs when the user is leaving your activity.

### <img src="/files/-M57ANEpqivIvTkxfou2" 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="/files/-M57ANEpqivIvTkxfou2" 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="/files/-M57E4BIzR4qP4xzIAqs" alt="" data-size="line"> View

### <img src="/files/-M57F0zpK981lh_1dKf9" alt="" data-size="line"> onClick

A simple Event when that specific widget is clicked.

### <img src="/files/-M3EpnBKB15OG_P4kSZB" 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="/files/-M57JvCpEPXCd04XMN6K" 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)](/files/-M57MHGPjzfdOajt_89t)

### <img src="/files/-M57PYgc8mAHICA3sudq" alt="" data-size="line"> onProgressChanged&#x20;

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

### <img src="/files/-M57PoZ9JcVuwXJcrxWN" alt="" data-size="line"> onStartTrackingTouch

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

### <img src="/files/-M57Q2l0d-920SPc8n9p" 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="/files/-M57QojFNqoNzwQeKesf" alt="" data-size="line"> onDateChange

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sketchwaredocs.gitbook.io/home/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
