# backPressed() not working on second activity

**URL:** <https://discourse.processing.org/t/backpressed-not-working-on-second-activity/17398>\
**Category:** Processing for Android\
**Created:** [January 28, 2020, 7:04pm UTC](https://discourse.processing.org/t/backpressed-not-working-on-second-activity/17398 "2020-01-28T19:04:05Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Post date:** [January 29, 2020, 9:42am UTC](https://discourse.processing.org/t/backpressed-not-working-on-second-activity/17398/3 "2020-01-29T09:42:22Z")

</div>

Maybe this helps you

> [@Android Studio + Processing](https://discourse.processing.org/t/android-studio-processing/12954):
>
> Hi, people wave!! After a while trying it, finally I made it. I’m capable to launch Sketches from P3 (Processing 3) in Android Studio and pass them some values. I don’t have many technical knowledge, but no one told me how to do it, so I want to share this example to people who have the same goal, to save time. Here is the code in AS: MainActivity: package processing.test.mixing1; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.suppo…

```auto
    @Override
    public void onBackPressed() {
        Intent gBack = new Intent(getActivity(),MainActivity.class);
        startActivity(gBack);
    }

```

---

_[View the full topic](https://discourse.processing.org/t/backpressed-not-working-on-second-activity/17398)._
