WebViewPool, Last html page show before new url when reuse WebView from WebViewPoolAndroid App development - WebView is not workingAndroid - setting WebViewClient causes NullPointerException in AsyncTaskandroid: camera onPause/onResume issueAndroid: BatteryLevel widget not updatingAndroid webview - Enable Private BrowsingWhy does my exception handler not trap Android SQLite insert error?setText on button from another activity androidSaving ToggleButton state in ListView by using SharedPreferencesUndo/Redo not working in android CanvasHow to implement parcelable with my custom class containing Hashmap and SparseArray?

Why does a simple loop result in ASYNC_NETWORK_IO waits?

How much character growth crosses the line into breaking the character

Hero deduces identity of a killer

Why Shazam when there is already Superman?

Creepy dinosaur pc game identification

Does Doodling or Improvising on the Piano Have Any Benefits?

What are the advantages of simplicial model categories over non-simplicial ones?

PTIJ: Haman's bad computer

Is aluminum electrical wire used on aircraft?

Can a Canadian Travel to the USA twice, less than 180 days each time?

What is the highest possible scrabble score for placing a single tile

Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typset

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

Recommended PCB layout understanding - ADM2572 datasheet

Multiplicative persistence

It grows, but water kills it

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?

Why would a new[] expression ever invoke a destructor?

Need help understanding what a natural log transformation is actually doing and why specific transformations are required for linear regression

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

Using substitution ciphers to generate new alphabets in a novel

Redundant comparison & "if" before assignment

How does a computer interpret real numbers?

I'm the sea and the sun



WebViewPool, Last html page show before new url when reuse WebView from WebViewPool


Android App development - WebView is not workingAndroid - setting WebViewClient causes NullPointerException in AsyncTaskandroid: camera onPause/onResume issueAndroid: BatteryLevel widget not updatingAndroid webview - Enable Private BrowsingWhy does my exception handler not trap Android SQLite insert error?setText on button from another activity androidSaving ToggleButton state in ListView by using SharedPreferencesUndo/Redo not working in android CanvasHow to implement parcelable with my custom class containing Hashmap and SparseArray?













0















There is a WebViewPool,when Activity/Fragment is destoryed,webview will be reset and add to the WebViewPool.



The following is the code of WebViewPool:




public class WebViewPool

private static volatile WebViewPool sINSTANCE;
private int mMaxSize;

private List<WebView> mAvailableList;
private List<WebView> mInUsedList;
private IWebViewPoolFactory mFactory;

private WebViewPool()



public static WebViewPool getInstance()
if (sINSTANCE == null)
synchronized (WebViewPool.class)
if (sINSTANCE == null)
sINSTANCE = new WebViewPool();



return sINSTANCE;


public void init(IWebViewPoolFactory factory,boolean lazy)
init(2, factory,lazy);


public void init(int maxSize, IWebViewPoolFactory factory,boolean lazy)
mMaxSize = maxSize;
mFactory = factory;
mAvailableList = new ArrayList<>(maxSize);
mInUsedList = new ArrayList<>(maxSize);
if (!lazy)
create();




private synchronized void create()
if (mFactory == null)
return;

for (int i = 0; i < mMaxSize; i++)
WebView webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));
mAvailableList.add(webView);



/**
* get webview form pool
* @param context
* @return
*/
public synchronized WebView getWebView(Context context)
if(!(context instanceof Activity))
throw new IllegalStateException("Context must be Activity");

WebView webView = null;
if (mAvailableList.size() > 0)
webView = mAvailableList.remove(0);

else
if (mFactory != null)
webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));


if (webView != null)
((MutableContextWrapper) webView.getContext()).setBaseContext(context);
mInUsedList.add(webView);

return webView;


/**
* reset/destroy webview when activity/fragemnt is destroyed
* @param webView
*/
public synchronized void restWebView(WebView webView)
if (webView == null



the following is some code of reset function:



 public void reset(WebView webView) 
if(webView==null)
return;

ViewParent viewParent = webView.getParent();
if (viewParent!=null)
((ViewGroup)viewParent).removeView(webView);

webView.stopLoading();
webView.clearCache(false);
webView.loadUrl("about:blank");
new Handler(Looper.getMainLooper()).postDelayed(new Runnable()
@Override
public void run()
webView.clearHistory();

, 1000);



But when reuse the webview,last html page show first before new url sometimes.It doesn't happened everytime. I searched in Google, but not work.Does anyone know the reason? Thank you!










share|improve this question




























    0















    There is a WebViewPool,when Activity/Fragment is destoryed,webview will be reset and add to the WebViewPool.



    The following is the code of WebViewPool:




    public class WebViewPool

    private static volatile WebViewPool sINSTANCE;
    private int mMaxSize;

    private List<WebView> mAvailableList;
    private List<WebView> mInUsedList;
    private IWebViewPoolFactory mFactory;

    private WebViewPool()



    public static WebViewPool getInstance()
    if (sINSTANCE == null)
    synchronized (WebViewPool.class)
    if (sINSTANCE == null)
    sINSTANCE = new WebViewPool();



    return sINSTANCE;


    public void init(IWebViewPoolFactory factory,boolean lazy)
    init(2, factory,lazy);


    public void init(int maxSize, IWebViewPoolFactory factory,boolean lazy)
    mMaxSize = maxSize;
    mFactory = factory;
    mAvailableList = new ArrayList<>(maxSize);
    mInUsedList = new ArrayList<>(maxSize);
    if (!lazy)
    create();




    private synchronized void create()
    if (mFactory == null)
    return;

    for (int i = 0; i < mMaxSize; i++)
    WebView webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));
    mAvailableList.add(webView);



    /**
    * get webview form pool
    * @param context
    * @return
    */
    public synchronized WebView getWebView(Context context)
    if(!(context instanceof Activity))
    throw new IllegalStateException("Context must be Activity");

    WebView webView = null;
    if (mAvailableList.size() > 0)
    webView = mAvailableList.remove(0);

    else
    if (mFactory != null)
    webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));


    if (webView != null)
    ((MutableContextWrapper) webView.getContext()).setBaseContext(context);
    mInUsedList.add(webView);

    return webView;


    /**
    * reset/destroy webview when activity/fragemnt is destroyed
    * @param webView
    */
    public synchronized void restWebView(WebView webView)
    if (webView == null



    the following is some code of reset function:



     public void reset(WebView webView) 
    if(webView==null)
    return;

    ViewParent viewParent = webView.getParent();
    if (viewParent!=null)
    ((ViewGroup)viewParent).removeView(webView);

    webView.stopLoading();
    webView.clearCache(false);
    webView.loadUrl("about:blank");
    new Handler(Looper.getMainLooper()).postDelayed(new Runnable()
    @Override
    public void run()
    webView.clearHistory();

    , 1000);



    But when reuse the webview,last html page show first before new url sometimes.It doesn't happened everytime. I searched in Google, but not work.Does anyone know the reason? Thank you!










    share|improve this question


























      0












      0








      0








      There is a WebViewPool,when Activity/Fragment is destoryed,webview will be reset and add to the WebViewPool.



      The following is the code of WebViewPool:




      public class WebViewPool

      private static volatile WebViewPool sINSTANCE;
      private int mMaxSize;

      private List<WebView> mAvailableList;
      private List<WebView> mInUsedList;
      private IWebViewPoolFactory mFactory;

      private WebViewPool()



      public static WebViewPool getInstance()
      if (sINSTANCE == null)
      synchronized (WebViewPool.class)
      if (sINSTANCE == null)
      sINSTANCE = new WebViewPool();



      return sINSTANCE;


      public void init(IWebViewPoolFactory factory,boolean lazy)
      init(2, factory,lazy);


      public void init(int maxSize, IWebViewPoolFactory factory,boolean lazy)
      mMaxSize = maxSize;
      mFactory = factory;
      mAvailableList = new ArrayList<>(maxSize);
      mInUsedList = new ArrayList<>(maxSize);
      if (!lazy)
      create();




      private synchronized void create()
      if (mFactory == null)
      return;

      for (int i = 0; i < mMaxSize; i++)
      WebView webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));
      mAvailableList.add(webView);



      /**
      * get webview form pool
      * @param context
      * @return
      */
      public synchronized WebView getWebView(Context context)
      if(!(context instanceof Activity))
      throw new IllegalStateException("Context must be Activity");

      WebView webView = null;
      if (mAvailableList.size() > 0)
      webView = mAvailableList.remove(0);

      else
      if (mFactory != null)
      webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));


      if (webView != null)
      ((MutableContextWrapper) webView.getContext()).setBaseContext(context);
      mInUsedList.add(webView);

      return webView;


      /**
      * reset/destroy webview when activity/fragemnt is destroyed
      * @param webView
      */
      public synchronized void restWebView(WebView webView)
      if (webView == null



      the following is some code of reset function:



       public void reset(WebView webView) 
      if(webView==null)
      return;

      ViewParent viewParent = webView.getParent();
      if (viewParent!=null)
      ((ViewGroup)viewParent).removeView(webView);

      webView.stopLoading();
      webView.clearCache(false);
      webView.loadUrl("about:blank");
      new Handler(Looper.getMainLooper()).postDelayed(new Runnable()
      @Override
      public void run()
      webView.clearHistory();

      , 1000);



      But when reuse the webview,last html page show first before new url sometimes.It doesn't happened everytime. I searched in Google, but not work.Does anyone know the reason? Thank you!










      share|improve this question
















      There is a WebViewPool,when Activity/Fragment is destoryed,webview will be reset and add to the WebViewPool.



      The following is the code of WebViewPool:




      public class WebViewPool

      private static volatile WebViewPool sINSTANCE;
      private int mMaxSize;

      private List<WebView> mAvailableList;
      private List<WebView> mInUsedList;
      private IWebViewPoolFactory mFactory;

      private WebViewPool()



      public static WebViewPool getInstance()
      if (sINSTANCE == null)
      synchronized (WebViewPool.class)
      if (sINSTANCE == null)
      sINSTANCE = new WebViewPool();



      return sINSTANCE;


      public void init(IWebViewPoolFactory factory,boolean lazy)
      init(2, factory,lazy);


      public void init(int maxSize, IWebViewPoolFactory factory,boolean lazy)
      mMaxSize = maxSize;
      mFactory = factory;
      mAvailableList = new ArrayList<>(maxSize);
      mInUsedList = new ArrayList<>(maxSize);
      if (!lazy)
      create();




      private synchronized void create()
      if (mFactory == null)
      return;

      for (int i = 0; i < mMaxSize; i++)
      WebView webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));
      mAvailableList.add(webView);



      /**
      * get webview form pool
      * @param context
      * @return
      */
      public synchronized WebView getWebView(Context context)
      if(!(context instanceof Activity))
      throw new IllegalStateException("Context must be Activity");

      WebView webView = null;
      if (mAvailableList.size() > 0)
      webView = mAvailableList.remove(0);

      else
      if (mFactory != null)
      webView = mFactory.create(new MutableContextWrapper(APP.getApplicationContext()));


      if (webView != null)
      ((MutableContextWrapper) webView.getContext()).setBaseContext(context);
      mInUsedList.add(webView);

      return webView;


      /**
      * reset/destroy webview when activity/fragemnt is destroyed
      * @param webView
      */
      public synchronized void restWebView(WebView webView)
      if (webView == null



      the following is some code of reset function:



       public void reset(WebView webView) 
      if(webView==null)
      return;

      ViewParent viewParent = webView.getParent();
      if (viewParent!=null)
      ((ViewGroup)viewParent).removeView(webView);

      webView.stopLoading();
      webView.clearCache(false);
      webView.loadUrl("about:blank");
      new Handler(Looper.getMainLooper()).postDelayed(new Runnable()
      @Override
      public void run()
      webView.clearHistory();

      , 1000);



      But when reuse the webview,last html page show first before new url sometimes.It doesn't happened everytime. I searched in Google, but not work.Does anyone know the reason? Thank you!







      android webview android-webview






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      zys

















      asked yesterday









      zyszys

      69921332




      69921332






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280539%2fwebviewpool-last-html-page-show-before-new-url-when-reuse-webview-from-webviewp%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280539%2fwebviewpool-last-html-page-show-before-new-url-when-reuse-webview-from-webviewp%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현