App Inventor Extensions

Take Screenshot Extension

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension or bug reports please start a new thread in the App Inventor community. Thank you.

For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.

Aug 11th, 2016: Version 1a: avoid DX execution failed error: build each extension separately

Sep 8th, 2016: Version 1b: provide error message in case something goes wrong

Sep 15th, 2021: Version 2: SDK30 adjustment to store the screenshot in the ASD - Application Specific Directory


Take Screenshot Extension to take a screenshot.
Required permission: none

Note: You also might be interested in the Screenshot Service Extension, which is able to take screenshots while your app is not running...


Return fileName of screenshot to be taken. Default filename is screenshot.jpg.

Set fileName of screenshot to be taken.


Take a screenshot.


Return image.

Example Use

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Questions and Answers

Q1: I am unable to get the screenshot of a web page. When I open it with web viewer, it shows perfectly but when I use the screenshot extension to share the screenshot of that, the chart area is removed automatically. Please let me know about any other ways or extensions which i could you for this.
A: Try the Component to Image Screenshot Extension by Jerin Jacob, which also can take screenshots of a webviewer page.

Q2: how to make user cannot take screenshot when open our apps?
A: Add the Disable Screen Capture Extension by Ken to every screen you want to prevent screenshots. Thank you Ken!

Java source code (Version 1)

package com.puravidaapps;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.os.Environment;



@DesignerComponent(version = TaifunScreenshot.VERSION,
    description = "Extension to take a screenshot.",
    category = ComponentCategory.EXTENSION,
    nonVisible = true,
    iconName = "")
@SimpleObject(external = true)
@UsesPermissions(permissionNames = "android.permission.WRITE_EXTERNAL_STORAGE")

public class TaifunScreenshot extends AndroidNonvisibleComponent implements Component {

  public static final int VERSION = 1;
  private ComponentContainer container;
  private Context context;
  private final Activity activity;
  private String fileName;
  private static final String LOG_TAG = "TaifunScreenshot";

  public TaifunScreenshot(ComponentContainer container) {
    this.container = container;
    context = (Context) container.$context();
    activity = (Activity) container.$context();
    fileName = "screenshot.jpg";
    Log.d(LOG_TAG, "TaifunScreenshot Created" );

   * Return fileName
  @SimpleProperty(category = PropertyCategory.BEHAVIOR,
      description = "filename of the screenshot to be taken")
  public String FileName() {
    return fileName;

   * Set fileName
  @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING,
      defaultValue = "screenshot.jpg")
  public void FileName(String fileName) {
    this.fileName = fileName;

   * Take a screenshot
  @SimpleFunction(description = "Take a screenshot.")
  public void TakeScreenshot() {
    // "
    try {
      // image naming and path  to include sd card  appending name you choose for file
      String mPath = Environment.getExternalStorageDirectory().toString() + File.separator + fileName;

      // create bitmap screen capture
      View v1 = activity.getWindow().getDecorView().getRootView();
      Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());

      File imageFile = new;

      FileOutputStream outputStream = new FileOutputStream(imageFile);
      int quality = 100;
      bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);

      Log.d(LOG_TAG, "screenshot taken: " + imageFile.toString());
    } catch (Throwable e) {
      // Several error may come out with file handling or OOM
      Log.e(LOG_TAG, e.getMessage(), e);

   * The AfterScreenshot event
  @SimpleEvent(description = "Return image.")
  public void AfterScreenshot(String image){
    EventDispatcher.dispatchEvent(this, "AfterScreenshot", image);


Terms and Conditions


Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to donate a small amount!

Donation amount:

or donate some mBTC to Bitcoin Address:

Thank you! Taifun

Download TaifunScreenshot extension (aix file)
Back to top of page ...

Creative Commons License
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.

Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact