2

I am trying to create a View of the current display so I can call the following methods to create a Bitmap:

 v1.setDrawingCacheEnabled(true);
 current = Bitmap.createBitmap(v1.getDrawingCache(), 1686, 136, (631-168), (343-136));
 v1.setDrawingCacheEnabled(false);

To create the View I tried this line

View v1 = mCurrentUrlMask.getRootView();

I got the error "Symbol 'mCurrentUrlMask' cannot be resolved."

I'm looking to create a bitmap of a section of the screen, and thoughts you have on this issue are greatly appreciated.

Elltz
10.9k4 gold badges33 silver badges60 bronze badges
asked May 30, 2015 at 20:51
3
  • who is mCurrentUrlMask ? Commented May 30, 2015 at 21:26
  • It was something I saw on stackoverflow Commented May 30, 2015 at 22:13
  • nice Sir, anyways always upvote helpful post and if it solves a problem accept it, happy coding sir, be good. Commented Jun 2, 2015 at 22:46

1 Answer 1

1

1

View v1 = MainActivity.this.getWindow().getDecorView();//editted
v1.buildDrawingCache();
//your rest of the code. 
// you will get a bitmap of the whole screen.

or you could use ViewSnapper

answered May 30, 2015 at 21:23
Sign up to request clarification or add additional context in comments.

12 Comments

I tried this and got the non-static method .getWindow() cannot be accessed from a static context. I'm using this code in the onStop(){} method.
Also .getWindow gets the current window for the activity. I'm looking to get the current screen regardless of what activity is in the foreground, this is in onStop(){} so it won't be in the foreground.
you made me smile; the Activity. was suppose to be your own activity reference okay, like this.getWindow() you get me sir?@JonathanAlexander and also you will need to put that in all your Activities unless you use something like ActivityGroup or FragmentActivity that you can for see others you get me, or you could check Display out, but its not what you want.
Oh okay I understand what you mean. I'll try it, thanks.
I did what you suggested and replaced activity with the reference to my activity (MainActivity) and got the same error. Is there something I'm not understanding?
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.