Hello,
I am trying to save a Picture that I got from webview.capturePicture
().
However from time to time for certain url the Picture saved is missing
some images...
I am saving/loading the Picture using writeToStream/createFromStream.
Is there any webview setting that I am missing?
here is the important part of the code :
@Override
public boolean onCreatePanelMenu(int featureId, Menu menu)
{
menu.add(Menu.NONE, 4545, 0, "load Url");
menu.add(Menu.NONE, 4546, 1, "direct display of the
picture"); //works correctly
menu.add(Menu.NONE, 4547, 1, "save pic");
menu.add(Menu.NONE, 4548, 1, "load pic"); //some images are
missing!
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item)
{
int id = item.getItemId();
if (id == 4545)
{
webView.loadUrl("http://www.misterdonut.jp/misdoclub/
index.html");
return true;
}
if (id == 4546)
{
MyImageView img = (MyImageView)findViewById(R.id.ImageView);
Picture pic = webView.capturePicture();
//this will call canvas.drawPicture(pic) on the next ondraw
call
img.setPicture(pic);
return true;
}
if (id == 4547)
{
Picture pic = webView.capturePicture();
//save the picture to a file
OutputStream os;
try {
Log.e("WebClient", " Start saving");
os = this.openFileOutput("testPicture",
ontext.MODE_WORLD_READABLE);
pic.writeToStream(os);
os.flush();
os.close();
Log.e("WebClient", "Finished saving");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
if (id == 4548)
{
//load and display the picture from a file
MyImageView img = (MyImageView)findViewById(R.id.ImageView);
InputStream is;
try {
is = this.openFileInput("testPicture");
Picture pic2 = Picture.createFromStream(is);
//this will call canvas.drawPicture(pic) on the next
ondraw
call
img.setPicture(pic2);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return true;
}
}
Thank you for the help!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---