# Help with invoking built in Android functions

**URL:** <https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061>\
**Category:** Processing for Android\
**Created:** [May 19, 2020, 4:00pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061 "2020-05-19T16:00:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![adaptinnovative](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@adaptinnovative](https://discourse.processing.org/u/adaptinnovative)\
**Post date:** [May 19, 2020, 4:00pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/1 "2020-05-19T16:00:41Z")

</div>

I am using APDE and it is great.

I want to invoke some of the built in functions on the Android device like

- Taking ascreenshot
- Turning on/off the wifi
- etc.

Are there specific lines of code to call these specific functions?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [May 19, 2020, 7:04pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/2 "2020-05-19T19:04:25Z")

</div>

To take a screenshot you can use processing’s functions. See [here.](https://processing.org/reference/PImage_get_.html)  
Almost everything can be done on Android but you have to do it programmatically.  
Try the following code and please comment on the Android mode/version that you are using.  
You will need the permissions ACCESS\_WIFI\_STATE and CHANGE\_WIFI\_STATE

```auto
import android.net.wifi.WifiManager;
import android.app.Activity;
import android.content.Context;

Activity act;
Context cnt;
boolean toggle;
WifiManager wifi;

void setup() {
  background(0, 0, 100); 
  fill(255);
  size(400, 400);
  textAlign(CENTER);
  textSize(25);
  text("Click to toggle Wifi On/Off", width/2, height/2);
  act = this.getActivity();
  cnt = act.getApplicationContext();
  wifi = (WifiManager) cnt.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
}

void draw() {
}

void mousePressed() {
  if (toggle) {
    wifi.setWifiEnabled(true);
    toggle = false;
  } else {
    wifi.setWifiEnabled(false);
    toggle = true;
  }
}

```

---

<div class="post-metadata">

**Author:** ![adaptinnovative](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@adaptinnovative](https://discourse.processing.org/u/adaptinnovative)\
**Post date:** [May 19, 2020, 9:20pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/3 "2020-05-19T21:20:56Z")

</div>

Thanks @noel I will check this now

---

<div class="post-metadata">

**Author:** ![adaptinnovative](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@adaptinnovative](https://discourse.processing.org/u/adaptinnovative)\
**Post date:** [May 19, 2020, 9:29pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/4 "2020-05-19T21:29:48Z")

</div>

Hi @noel I tried it on APDE and the app crashed. I have to try it on Processing [Android Mode] using Processing 1.5.1 in a sec

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [May 19, 2020, 9:41pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/5 "2020-05-19T21:41:39Z")

</div>

To give permissions on APDE you use the three dots right top, Sketch Properties / Sketch Permissions.  
With Api I mean [this](https://en.wikipedia.org/wiki/Android_version_history).

---

<div class="post-metadata">

**Author:** ![adaptinnovative](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@adaptinnovative](https://discourse.processing.org/u/adaptinnovative)\
**Post date:** [May 20, 2020, 2:00am UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/6 "2020-05-20T02:00:09Z")

</div>

Thanks I did that and it is enabled. APDE still crashes

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [May 21, 2020, 1:16pm UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/7 "2020-05-21T13:16:37Z")

</div>

@adaptinnovative === the app crashes: what error message? - What is the os of your phone?

---

<div class="post-metadata">

**Author:** ![adaptinnovative](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@adaptinnovative](https://discourse.processing.org/u/adaptinnovative)\
**Post date:** [April 27, 2026, 3:07am UTC](https://discourse.processing.org/t/help-with-invoking-built-in-android-functions/21061/8 "2026-04-27T03:07:30Z")

</div>

i will confirm the app error
