Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:46:24+00:00 2026-06-11T12:46:24+00:00

I used a screenshot plugin for ios when I developed an iphone/ipad app. I

  • 0

I used a screenshot plugin for ios when I developed an iphone/ipad app. I am now creating an android version of the app and am trying to implement the android version of the plugin.

My java part fo the plugin looks like this:

package org.apache.cordova;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;

import android.graphics.Bitmap;
import android.os.Environment;
import android.view.View;

public class Screenshot extends Plugin {
private PluginResult result = null;

@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
    // starting on ICS, some WebView methods
    // can only be called on UI threads
    super.cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            View view = webView.getRootView();

            view.setDrawingCacheEnabled(true);
            Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
            view.setDrawingCacheEnabled(false);

            try {
                File folder = new File(Environment.getExternalStorageDirectory(), "Pictures");
                if (!folder.exists()) {
                    folder.mkdirs();
                }

                File f = new File(folder, "screenshot_" + System.currentTimeMillis() + ".png");

                FileOutputStream fos = new FileOutputStream(f);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
                result = new PluginResult(PluginResult.Status.OK);

            } catch (IOException e) {
                result = new PluginResult(PluginResult.Status.IO_EXCEPTION, e.getMessage());
            }
        }
    });

    // waiting ui thread to finish
    while (this.result == null) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            // ignoring exception, since we have to wait
            // ui thread to finish
        }
    }

    return this.result;
}

}

My Screenshot.js looks like this:

(function() {
/* Get local ref to global PhoneGap/Cordova/cordova object for exec function.
    - This increases the compatibility of the plugin. */
var cordovaRef = window.PhoneGap || window.Cordova || window.cordova; // old to new fallbacks

/**
 * This class exposes the ability to take a Screenshot to JavaScript
 */
function Screenshot() { }

/**
 * Save the screenshot to the user's Photo Library
 */
Screenshot.prototype.saveScreenshot = function() {
cordovaRef.exec(null, null, "Screenshot", "saveScreenshot", []);
};

    if (!window.plugins) {
        window.plugins = {};
    }
    if (!window.plugins.screenshot) {
        window.plugins.screenshot = new Screenshot();
    }

 })(); /* End of Temporary Scope. */

Now I try to call my screenshot.js function by using this code:

function takeScreenShot() {
  cordovaRef.exec("Screenshot.saveScreenshot");
}   

However all I get is JSON errors, I know somewhere im asking to to convert it to JSON from a java string but i just can’t figure out how to change it. Ok well I think that is what is wrong…

My errors look like this:

ERROR: org.json.JSONException: Value undefined of type java.lang.String cannot be converted to JSONArray.
Error: Status=8 Message=JSON error
file:///android_asset/www/cordova-2.0.0.js: Line 938 :  Error: Status=8 Message=JSON error
Error: Status=8 Message=JSON error at file:///android_asset_/www/cordova-2.0.0.js:938

Can anyone guide me where Im going wrong please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:46:25+00:00Added an answer on June 11, 2026 at 12:46 pm

    Question resolved by:

    Phonegap Screenshot plugin in Cordova 2.0.0

    Answer provided by Simon MacDonald.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used Twitter-OAuth-iPhone to synchronize the message in my app. It's all right in
What control is used to implement the application screenshot preview in the windows phone
Just came across the Piictu iOS app ( Screenshot ). The UI looks great
i had used this plugin before, but now when i want to use it
I am using PhoneGap along with the associated Screenshot Plugin for iOS. It is
We are developing an HTML5 + CSS3 application for iPad and iPhone. The app
I used the phonegap website to create an IPA file. Now I want to
Having used storyboards for a while now I have found them extremely useful however,
I have an app that takes a screenshot and the shares this with the
I want to know the command used in this screenshot to monitor the active

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.