I've yet to find an answer for this and it seems like such a simple task.
I need to be able to find the WebView that Phonegap uses when it calls:
super.loadUrl("file:///android_asset/www/index.html");
I've tried creating a new WebView in the main.xml file and loading the index.html page into it which only causes a Null Pointer Exception.
Any help would be great.
///
Edit:
The code below appears to now actually take a screenshot of the view as the file has a size of 823bytes..however, it is displaying as just a black image, nothing is shown..
Could this be to it taking a screenshot too quickly, before the view is loaded? or am I doing something else wrong?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
View html = (View)super.appView.getParent();
Bitmap bm2 = Bitmap.createBitmap(200, 300, Bitmap.Config.ARGB_8888);
Canvas c2 = new Canvas(bm2);
html.draw(c2);
OutputStream stream = null;
try {
stream = new FileOutputStream(Environment.getExternalStorageDirectory() +"/bm2.png");
bm2.compress(CompressFormat.PNG, 80, stream);
if (stream != null) stream.close();
} catch (IOException e) {
} finally {
bm2.recycle();
}
}//end