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
1 Answer 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
Elltz
10.9k4 gold badges33 silver badges60 bronze badges
Sign up to request clarification or add additional context in comments.
12 Comments
Jon
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.
Jon
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.
Elltz
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.Jon
Oh okay I understand what you mean. I'll try it, thanks.
Jon
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?
|
lang-java
mCurrentUrlMask?