How can I get the JSON response of a POST request in a WebView?

You should override the shouldOverrideUrlLoading method of WebViewClient @Override public boolean shouldOverrideUrlLoading (WebView view, String url) { if(flag) { URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); // read inputstream to get the json.. … … return true; } return false } @override public void onPageFinished (WebView view, String … Read more

How to Hide ActionBar/Toolbar While Scrolling Down in Webview

You can do this without any Java code using the design library’s CoordinatorLayout and NestedScrollView, with app:layout_scrollFlags set on Toolbar. Here’s how you do it. <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”match_parent”> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:background=”?attr/colorPrimary” app:layout_scrollFlags=”scroll|enterAlways” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light” /> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_gravity=”fill_vertical” android:fillViewport=”true” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <WebView android:id=”@+id/webview” android:layout_width=”match_parent” … Read more

Why Bitmap to Base64 String showing black background on webview in android?

The JPEG format does not support alpha transparency, which is why the transparent background becomes black when you convert your original image to JPEG. Use the PNG format instead: map1.compress(Bitmap.CompressFormat.PNG, 100, baos); and String imgTag = “<img src=”data:image/png;base64,” + imgToString + “” align=’left’ bgcolor=”ff0000″/>”;

Two way sync for cookies between HttpURLConnection (java.net.CookieManager) and WebView (android.webkit.CookieManager)

I’ve implemented my own idea. It’s actually pretty cool. I’ve created my own implementation of java.net.CookieManager which forwards all requests to the WebViews’ webkit android.webkit.CookieManager. This means no sync is required and HttpURLConnection uses the same cookie storage as the WebViews. Class WebkitCookieManagerProxy: import java.io.IOException; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.CookieStore; import java.net.URI; import java.util.Arrays; … Read more