1

Is it possible to programmatically take a screenshot of an activity that is currently not displayed? Maybe using findViewById()?

I would want my app to take a screenshot of another activity after a button press in the current activity.

Why won't something like this work?

    Bitmap screen; View v1 = findViewById(R.id.someView);
    v1.setDrawingCacheEnabled(true);
    screen = Bitmap.createBitmap(v1.getDrawingCache());
    v1.setDrawingCacheEnabled(false);
  • I not am sure you searched the Stackoverflow for similar questions, never mind, see if this helps https://stackoverflow.com/a/30212385/380161 – Anupam Saini Jun 13 '17 at 10:40
  • I would want my app to take a screenshot of another activity after a button press in the current activity.....could you elaborate more on that..did'nt quite get what you want to achieve here – Akshay Jun 13 '17 at 10:41
  • Sorry, that was poorly worded. Let's say I have activity1 and it has a button that says "take screenshot". I also have activity2 in my app that has some content (like graphs). My goal is when the user presses the screenshot button in activity1, the application takes a screenshot of activity2. I don't know if this is even possible and that's why I asked :) – cashmoneyscience Jun 13 '17 at 10:45
  • https://stackoverflow.com/questions/5604125/android-taking-screenshot-of-offscreen-page could be helpful – Akshay Jun 13 '17 at 10:48

1 Answers1

0

I would want my app to take a screenshot of another activity after a button press in the current activity.

If the other Activity is running in the background, you can convert the View into Bitmap by notifying it via LocalBroadcast events. cheers :)

Darish
  • 11,032
  • 5
  • 50
  • 70