Android WebView Protocol Handler

I am trying to develop an application for the Android browser using WebView , which allows users to access content from a user protocol. The user protocol may be foobar: //

I want to intercept all requests to this custom protocol. It means:

  • GET requests
  • POST Requests

and I need to be able to pass the results of these operations back to the WebView.

GET requests can be processed using shouldInterceptRequest (available at API level 11).

Now my problem is: How can I make and process POST requests ?

Almost the same question was asked here and here , but no solutions to their problems were found.

+6
source share
1 answer

You tried to override the post method by doing something like:

private class ViewerWebViewClient extends WebViewClient { @Override public void onPageFinished( WebView view, String url ) { } @Override public boolean shouldOverrideUrlLoading( WebView view, final String url ) { if(!url.contains(MYKEYWORD)) { Toast.makeText(getActivity(),POSTING, Toast.LENGTH_LONG).show(); return true; } return super.shouldOverrideUrlLoading(view, url); } } 

its just an idea. maybe can help you.

0
source

Source: https://habr.com/ru/post/902788/


All Articles