Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Screenshot plugin for Cordova/phoneGap apps.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 984
    Comment on it

    Hello Readers,

    Screenshot plugin for Cordova/phonegap apps allows you to take screenshot of the current open screen and save it to phone storage.

     

    First of all we need to install the following plugin through CLI:

    $ cordova plugin add https://github.com/gitawego/cordova-screenshot.git

     

    Usage :

    navigator.screenshot.save(function(error,res){
      if(error)
      {
          console.error(error);
      }
      else
      {
          console.log('ok',res.filePath);
      }
    });

    In the above code we can take a screenshot of the current screen and it will save in device storage.

     

    We can save a screenshot with jpg and custom quality.

    For example:

    navigator.screenshot.save(function(error,res){
       if(error)
       {
           console.error(error);
       }
       else
       {
          console.log('ok',res.filePath);
       }
    },'jpg',50);

    In the above code we'll see we have defined the jpg format and screenshot quality 50.

     

    We can define the name of screenshot file in the options.

    navigator.screenshot.save(function(error,res){
        if(error)
        {
            console.error(error);
        }
        else
        {
           console.log('ok',res.filePath); //should be path/to/screenshots.jpg
        }
    },'jpg',50,'screenshots');

    In the above code i have defined the file's name "screenshots".

     

    For more details visit: Click here . Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: