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 8731975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:21:18+00:00 2026-06-13T09:21:18+00:00

Ok so im trying to figure out how i can tweak this code to

  • 0

Ok so im trying to figure out how i can tweak this code to be able to save the image instead of /sdcard i want to save it somewhere like /sdcard/folder/Screenshot_xxxxx.jpg ,

Here is the code below.

  case R.id.settings_capture:
                item.setIcon(R.drawable.capture);                   
                //Resize the webview to the height of the webpage
                int pageHeight = web.getContentHeight();
                LayoutParams browserParams = web.getLayoutParams();
                web.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, pageHeight));

                //Capture the webview as a bitmap
                web.setDrawingCacheEnabled(true);
                Bitmap bitmap = Bitmap.createBitmap(web.getDrawingCache());
                web.setDrawingCacheEnabled(false);

                //Create the filename to use
                String randomFilenamepart = String.valueOf(new SecureRandom().nextInt(1000000));
                String filename = Environment.getExternalStorageDirectory().toString() + "/ScreenShot_" + randomFilenamepart + ".jpg";

                File imageFile = new File(filename);
                //Stream the file out to external storage as a JPEG
                OutputStream fout = null;
                try {
                    fout = new FileOutputStream(imageFile);
                    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
                    fout.flush();
                    fout.close();
                    Toast.makeText(WebViewClientDemoActivity.this, "Screen Capture Saved!\n\nImage Saved at location : /sdcard\n\nSaved As: ScreenShot_xxxxx.jpg", Toast.LENGTH_LONG).show();
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                    Toast.makeText(WebViewClientDemoActivity.this, "Problem with Capturing Image or Location to Store Image", Toast.LENGTH_SHORT).show();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    web.setLayoutParams(browserParams);
                }

So my main goal is to modify code to where i can save this in a specific location, such as the apps own folder on the sdcard.

Thanks for any help, comments, source code examples, external links. I appreciate it in advance.

  • 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-13T09:21:19+00:00Added an answer on June 13, 2026 at 9:21 am

    This Resolved my issue

     case R.id.settings_capture:
                    item.setIcon(R.drawable.capture);                   
                    //Resize the webview to the height of the webpage
                    int pageHeight = web.getContentHeight();
                    LayoutParams browserParams = web.getLayoutParams();
                    web.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, pageHeight));
    
                    //Capture the webview as a bitmap
                    web.setDrawingCacheEnabled(true);
                    Bitmap bitmap = Bitmap.createBitmap(web.getDrawingCache());
                    web.setDrawingCacheEnabled(false);
    
                   // final DateFormat DF = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS");
                    String out = new SimpleDateFormat("EEE_MMM_dd_yyyy hh:mm.s'.jpg'").format(new Date());
    
                    //Create the filename to use
                    String target_filename  = "FolderName-" + (out);
                            //+ ".jpg";
                    try {
                        File targetDir = new File(Environment.getExternalStorageDirectory(), "/Enlighten");
                    if (!targetDir.exists()){   
                        targetDir.mkdirs(); }
                        File file = new File(targetDir, target_filename);
                        FileOutputStream fos = new FileOutputStream(file);
                        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
                        fos.flush();
                        fos.close();
                        Toast.makeText(WebViewClientDemoActivity.this, "Capture Saved!\n\nImage Stored @ /sdcard/Location", Toast.LENGTH_LONG).show();
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                        Toast.makeText(WebViewClientDemoActivity.this, "Problem Storing Image To: /sdcard/Location", Toast.LENGTH_LONG).show();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } finally {
                        web.setLayoutParams(browserParams);
                    }
                    return true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out how I can do this properly. The print_r looks like
I'm trying to figure out if I can get what I want out of
I'm trying to figure out what can cause this error in Java: Invalid access
im trying to figure out how i can do this. i have a list
I am trying to figure out how can I update the petevents table with
I trying to figure out how I can delete from multiple tables in SQL
I'm trying to figure out how I can listen to the Cancel button that
I'm trying to figure out why I can't I use super in a generic
I am trying to figure out how I can tell, in MATLAB, how many
I'm trying to figure out how I can download a particular tag of a

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.