28

The Android Developers reference says that both the WebView.PictureListener interface and its onNewPicture() method are deprecated.

Fine, but the need to know when WebView renders a picture is still there. Is there an alternative way to accomplishing this?

uTubeFan
  • 6,664
  • 12
  • 41
  • 65
  • 1
    Same question here: http://stackoverflow.com/questions/7166534/picturelistener-is-deprecated-and-obsolete-is-there-a-replacement/7877879#7877879 – ciscogambo Oct 24 '11 at 16:31
  • Isn't that what onLoadResource() is for? Maybe I'm wrong. How about overloading this, calling super.onLoadResource() and then checking for the file type? – Emmanuel Oct 24 '11 at 15:17
  • @ciscogambo Your reference to ActivityManager.restartPackage() makes your Aug 23 question less clear and focused than this one. It's strange that no one has been able to come with an answer since Aug 23. Perhaps the lack of a replacement is intentional? Security reasons? – Android Eve Oct 24 '11 at 18:39
  • Thanks @AndroidEve, I cleaned removed that from my question. – ciscogambo Oct 25 '11 at 03:33
  • it has been 5 years but they haven't created alternative. – hardik9850 Jun 22 '16 at 06:20

4 Answers4

8

Ok after careful review of the APIs, it seems this cannot be done without using PictureListener. Obviously the person who deprecated this feature didn't provide an alternative.

I suggest you write a bug report http://code.google.com/p/android/issues and ask people here to star it.

Emmanuel

Emmanuel
  • 16,791
  • 6
  • 48
  • 74
5

I submitted this Android issue to track the replacement for the PictureListener and onNewPicture() callback.

http://code.google.com/p/android/issues/detail?id=38646

Please star as necessary.

Douglas Hill
  • 170
  • 2
  • 7
1

Until there is an official replacement API for this functionality you can just change the

android:targetSdkVersion

in AndroidManifest.xml to anything <= 13.

Unknown
  • 11
  • 1
1

the closest thing you have is onPageFinished

wv.setWebViewClient(new WebViewClient() {
  @Override
  public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

  }
});

but it doesn't always trigger after the content is finished being drawn, hence not so much of a replacement. I suggest sticking to onNewPicture even if it is deprecated. after all, it still works.

josephus
  • 8,284
  • 1
  • 37
  • 57