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

  • Home
  • SEARCH
  • 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 6031787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:14:13+00:00 2026-05-23T05:14:13+00:00

I need to take a screen shot and save the screen shot. I need

  • 0

I need to take a screen shot and save the screen shot. I need to do this without using any connection to PC or without unrooting the phone. I need to do this whenever a event is triggered . For example when an ad is shown in a game … or when the game ends and shows the scores in snake etc. Can you please let me know How Can i do this. I saw some tutorilas and they gave the code but that doesnt seem to work

private void getScreen()
   {
    View content = findViewById(R.id.layoutRoot);
    Bitmap bitmap = content.getDrawingCache();
    File file = new File("/sdcard/test.png");
    try 
    {
        file.createNewFile();
        FileOutputStream ostream = new FileOutputStream(file);
        bitmap.compress(CompressFormat.PNG, 100, ostream);
        ostream.close();
    } 
    catch (Exception e) 
    {
        e.printStackTrace();
    }
}
  • 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-05-23T05:14:14+00:00Added an answer on May 23, 2026 at 5:14 am

    Can you give more information as to what does not work when you run that code ? Does it not capture what you want ? Does it crash ?

    Make sure you change the R.id.layoutroot correctly with your root layout… Beside that it seems like it would work…

    <com.example.android.snake.SnakeView
     android:id="@+id/snake"
        android:layout_width="match_parent"
                android:layout_height="match_parent"
                tileSize="24"
                />
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <TextView
         android:id="@+id/text"
            android:text="@string/snake_layout_text_text"
            android:visibility="visible"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center_horizontal"
            android:textColor="#ff8888ff"
            android:textSize="24sp"/>
    </RelativeLayout>
    

    Edit…

    So for example, if you use that layout you just put there, you should change the R.id.layout into R.id.snake, that’s because of this line : android:id="@+id/snake".

    I don’t think there is an easy way to find /get the id of the “root” layout of a view (if you wanted to take screenshot of anything the phone is showing.

    I just checked the launcher and another application, seems like most app are placed into a FrameLayout with id/content, so you can try to use android.R.id.content, but there is no guaranty this will work every time…

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

Sidebar

Related Questions

I need to take a screen shot of some charts in my app, Im
I need to take a screen shot and convert that screen shot to a
Need to take a SELECT drop down list options and find if any of
I need to take production data with real customer info (names, address, phone numbers,
I need to take an existing winforms application and drop into an event tracing
I am developing a java application. I have scenario to take screen shot of
I want to take a screen shot in android irrespective of the application and
I am using Selenium RC using c# and need to take screenshot for the
I have a screen shot I take in my mobile app. The screen shot
I'm working on a file sharing website, I need a way to take screenshots

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.