<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WebView Archives - Codeplaners</title>
	<atom:link href="https://codeplaners.com/tag/webview/feed/" rel="self" type="application/rss+xml" />
	<link>https://codeplaners.com/tag/webview/</link>
	<description>Code Solution</description>
	<lastBuildDate>Tue, 27 Jul 2021 23:43:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>

<image>
	<url>https://codeplaners.com/wp-content/uploads/2020/09/cropped-favicon-social-32x32.png</url>
	<title>WebView Archives - Codeplaners</title>
	<link>https://codeplaners.com/tag/webview/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Webview App Youtube Video Full Screen Example</title>
		<link>https://codeplaners.com/webview-app-youtube-video-full-screen-example/</link>
					<comments>https://codeplaners.com/webview-app-youtube-video-full-screen-example/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 27 Jul 2021 23:41:14 +0000</pubDate>
				<category><![CDATA[Android Studio]]></category>
		<category><![CDATA[Android Studio Webview]]></category>
		<category><![CDATA[WebView]]></category>
		<guid isPermaLink="false">https://codeplaners.com/?p=1110</guid>

					<description><![CDATA[<p>Hi Dev, Today, i we will show you webview app youtube video full screen example. This article will give you simple example of webview app youtube video full screen example. you will learn webview app youtube video full screen example. So let’s follow few step to create example of webview app youtube video full screen &#8230; <a href="https://codeplaners.com/webview-app-youtube-video-full-screen-example/" class="more-link">Continue reading<span class="screen-reader-text"> "Webview App Youtube Video Full Screen Example"</span></a></p>
<p>The post <a rel="nofollow" href="https://codeplaners.com/webview-app-youtube-video-full-screen-example/">Webview App Youtube Video Full Screen Example</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi Dev,</p>
<p>Today, i we will show you webview app youtube video full screen example. This article will give you simple example of webview app youtube video full screen example. you will learn webview app youtube video full screen example. So let’s follow few step to create example of webview app youtube video full screen example.</p>
<p><strong>MainActivity</strong></p>
<pre class="brush: java; title: ; notranslate">
WebView mWebView;


    @SuppressLint(&quot;SetJavaScriptEnabled&quot;)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        mWebView = (WebView) findViewById(R.id.webView);


        mWebView.setWebViewClient(new WebViewClient());
        mWebView.setWebChromeClient(new MyChrome());    // here
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAllowFileAccess(true);
        webSettings.setAppCacheEnabled(true);

       if (savedInstanceState == null) {
          mWebView.loadUrl(&quot;https://www.youtube.com/&quot;);
       }

    }


    private class MyChrome extends WebChromeClient {

        private View mCustomView;
        private WebChromeClient.CustomViewCallback mCustomViewCallback;
        protected FrameLayout mFullscreenContainer;
        private int mOriginalOrientation;
        private int mOriginalSystemUiVisibility;

        MyChrome() {}

        public Bitmap getDefaultVideoPoster()
        {
            if (mCustomView == null) {
                return null;
            }
            return BitmapFactory.decodeResource(getApplicationContext().getResources(), 2130837573);
        }

        public void onHideCustomView()
        {
            ((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomView);
            this.mCustomView = null;
            getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
            setRequestedOrientation(this.mOriginalOrientation);
            this.mCustomViewCallback.onCustomViewHidden();
            this.mCustomViewCallback = null;
        }

        public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
        {
            if (this.mCustomView != null)
            {
                onHideCustomView();
                return;
            }
            this.mCustomView = paramView;
            this.mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();
            this.mOriginalOrientation = getRequestedOrientation();
            this.mCustomViewCallback = paramCustomViewCallback;
            ((FrameLayout)getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
            getWindow().getDecorView().setSystemUiVisibility(3846 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        }
    }

}
</pre>
<p><strong>AndroidManifest.xml</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;activity
  android:name=&quot;.MainActivity&quot;
  android:configChanges=&quot;orientation|screenSize&quot; /&gt;
</pre>
<p>The post <a rel="nofollow" href="https://codeplaners.com/webview-app-youtube-video-full-screen-example/">Webview App Youtube Video Full Screen Example</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codeplaners.com/webview-app-youtube-video-full-screen-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to create WebView App using Kotlin</title>
		<link>https://codeplaners.com/how-to-create-webview-app-using-kotlin/</link>
					<comments>https://codeplaners.com/how-to-create-webview-app-using-kotlin/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 19 May 2021 00:29:02 +0000</pubDate>
				<category><![CDATA[Android Studio]]></category>
		<category><![CDATA[Android Studio Webview]]></category>
		<category><![CDATA[Android Webview]]></category>
		<category><![CDATA[Kotlin]]></category>
		<category><![CDATA[WebView]]></category>
		<category><![CDATA[Webview App]]></category>
		<guid isPermaLink="false">https://codeplaners.com/?p=763</guid>

					<description><![CDATA[<p>Hello Dev, Today, i we will show you How to create WebView App using Kotlin. This article will give you simple example of How to create WebView App using Kotlin. you will learn How to create WebView App using Kotlin. So let&#8217;s follow few step to create example of How to create WebView App using &#8230; <a href="https://codeplaners.com/how-to-create-webview-app-using-kotlin/" class="more-link">Continue reading<span class="screen-reader-text"> "How to create WebView App using Kotlin"</span></a></p>
<p>The post <a rel="nofollow" href="https://codeplaners.com/how-to-create-webview-app-using-kotlin/">How to create WebView App using Kotlin</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hello Dev,</p>
<p>Today, i we will show you How to create WebView App using Kotlin. This article will give you simple example of How to create WebView App using Kotlin. you will learn How to create WebView App using Kotlin. So let&#8217;s follow few step to create example of How to create WebView App using Kotlin.</p>
<p>Create a new project in Android Studio</p>
<h3>Step 1:- Add the following code to activity_main.xml</h3>
<pre class="brush: java; title: ; notranslate">
&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;
   android:layout_width=&quot;match_parent&quot;
   android:layout_height=&quot;match_parent&quot;
   tools:context=&quot;.MainActivity&quot;&gt;
   &lt;WebView
      android:id=&quot;@+id/webView&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
   &lt;/WebView&gt;
&lt;/RelativeLayout&gt;
</pre>
<h3>Step 2:- Add the following code to src/MainActivity.kt</h3>
<pre class="brush: java; title: ; notranslate">
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   private val webView: WebView? = null
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = &quot;KotlinApp&quot;
      val webView = findViewById&lt;WebView&gt;(R.id.webView)
      webView.webViewClient = WebViewClient()
      webView.loadUrl(&quot;https://www.google.com&quot;)
      val webSettings = webView.settings
      webSettings.javaScriptEnabled = true
   }
   override fun onBackPressed() {
      if (webView!!.canGoBack()) {
         webView.goBack()
      } else {
         super.onBackPressed()
      }
   }
}
</pre>
<h3>Step 3:- Add the following code to androidManifest.xml</h3>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; package=&quot;app.com.myapplication&quot;&gt;
   &lt;application
   android:allowBackup=&quot;true&quot;
   android:icon=&quot;@mipmap/ic_launcher&quot;
   android:label=&quot;@string/app_name&quot;
   android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
   android:supportsRtl=&quot;true&quot;
   android:theme=&quot;@style/AppTheme&quot;&gt;
      &lt;activity android:name=&quot;.MainActivity&quot;&gt;
         &lt;intent-filter&gt;
            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
         &lt;/intent-filter&gt;
      &lt;/activity&gt;
   &lt;/application&gt;
&lt;/manifest&gt;
</pre>
<p>The post <a rel="nofollow" href="https://codeplaners.com/how-to-create-webview-app-using-kotlin/">How to create WebView App using Kotlin</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codeplaners.com/how-to-create-webview-app-using-kotlin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Android WebView ProgessBar while loading</title>
		<link>https://codeplaners.com/android-webview-progessbar-while-loading/</link>
					<comments>https://codeplaners.com/android-webview-progessbar-while-loading/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 23 Apr 2021 07:52:27 +0000</pubDate>
				<category><![CDATA[Android Studio]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Android Webview]]></category>
		<category><![CDATA[WebView]]></category>
		<guid isPermaLink="false">https://codeplaners.com/?p=600</guid>

					<description><![CDATA[<p>In this article, we will show you Android WebView ProgessBar while loading . This article will give you simple example of Android WebView ProgessBar while loading . you will learn Android WebView ProgessBar while loading. code copy and past main.java file final ProgressDialog progressBar = new ProgressDialog(MainActivity.this); progressBar.setMessage(&#34;Please wait...&#34;); webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView &#8230; <a href="https://codeplaners.com/android-webview-progessbar-while-loading/" class="more-link">Continue reading<span class="screen-reader-text"> "Android WebView ProgessBar while loading"</span></a></p>
<p>The post <a rel="nofollow" href="https://codeplaners.com/android-webview-progessbar-while-loading/">Android WebView ProgessBar while loading</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article, we will show you Android WebView ProgessBar while loading . This article will give you simple example of Android WebView ProgessBar while loading . you will learn Android WebView ProgessBar while loading.</p>
<p><strong>code copy and past  main.java file</strong></p>
<pre class="brush: java; title: ; notranslate">
        final ProgressDialog progressBar = new ProgressDialog(MainActivity.this);
        progressBar.setMessage(&quot;Please wait...&quot;);

        webView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
               view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                if (!progressBar.isShowing()) {
                   progressBar.show();
               }
           }

            public void onPageFinished(WebView view, String url) {
                if (progressBar.isShowing()) {
                    progressBar.dismiss();
               }
            }

            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
               if (progressBar.isShowing()) {
                    progressBar.dismiss();
                }
            }
        });
</pre>
<h3>This is how to insert,<strong> MainActivity.java</strong> file</h3>
<pre class="brush: java; title: ; notranslate">
public class MainActivity extends Activity
{
    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webView);

        final ProgressDialog progressBar = new ProgressDialog(MainActivity.this);
        progressBar.setMessage(&quot;Please wait...&quot;);

        webView.loadUrl(&quot;https://codeplaners.com/&quot;);
        webView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                if (!progressBar.isShowing()) {
                    progressBar.show();
                }
            }

            public void onPageFinished(WebView view, String url) {
                if (progressBar.isShowing()) {
                    progressBar.dismiss();
                }
            }

            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                if (progressBar.isShowing()) {
                    progressBar.dismiss();
                }
            }
        });

    }
}
</pre>
<p>The post <a rel="nofollow" href="https://codeplaners.com/android-webview-progessbar-while-loading/">Android WebView ProgessBar while loading</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codeplaners.com/android-webview-progessbar-while-loading/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Android Studio Webview App</title>
		<link>https://codeplaners.com/android-studio-webview-app/</link>
					<comments>https://codeplaners.com/android-studio-webview-app/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 08 Mar 2021 12:25:17 +0000</pubDate>
				<category><![CDATA[Android Studio]]></category>
		<category><![CDATA[Android Studio Webview]]></category>
		<category><![CDATA[Android Webview]]></category>
		<category><![CDATA[WebView]]></category>
		<category><![CDATA[Webview App]]></category>
		<guid isPermaLink="false">https://codeplaners.com/?p=458</guid>

					<description><![CDATA[<p>This post was last updated on May 17th, 2021 at 12:20 amAndroid WebView is employed to show web content in android. the online page may be loaded from same application or uniform resource locator. it&#8217;s accustomed show on-line content in android activity. How can we add SwipeRefreshLayout and file selector and splashscreen to webview app. &#8230; <a href="https://codeplaners.com/android-studio-webview-app/" class="more-link">Continue reading<span class="screen-reader-text"> "Android Studio Webview App"</span></a></p>
<p>The post <a rel="nofollow" href="https://codeplaners.com/android-studio-webview-app/">Android Studio Webview App</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="last-modified">This post was last updated on May 17th, 2021 at 12:20 am</p><p>Android WebView is employed to show web content in android. the online page may be loaded from same application or uniform resource locator. it&#8217;s accustomed show on-line content in android activity.</p>
<p>How can we add SwipeRefreshLayout and file selector and splashscreen to webview app. read the full post.</p>
<p>Now open activity_main.xml file from /res/layout path and write the code like as shown below</p>
<h3>activity_main.xml</h3>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;android.support.constraint.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    tools:context=&quot;.MainActivity&quot;&gt;


    &lt;ProgressBar
        android:id=&quot;@+id/progressBar&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        style=&quot;@style/Widget.AppCompat.ProgressBar.Horizontal&quot;
        android:visibility=&quot;gone&quot;/&gt;

    &lt;android.support.v4.widget.SwipeRefreshLayout
        android:id=&quot;@+id/swipe&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot;&gt;

        &lt;WebView
            android:id=&quot;@+id/webview&quot;
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;match_parent&quot; /&gt;

    &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;


&lt;/android.support.constraint.ConstraintLayout&gt;
</pre>
<p>Now open MainActivity.java from \java\com.codeplaners path and write the code like as shown below</p>
<h3>MainActivity.java</h3>
<pre class="brush: java; title: ; notranslate">
package com.codeplaners;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.view.WindowManager;
import android.view.Window;
import android.support.v7.app.AlertDialog;
import android.content.DialogInterface;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;


import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.util.Log;
import android.webkit.ValueCallback;
import android.widget.Toast;
import java.io.File;
import java.io.IOException;
import android.webkit.WebChromeClient;
import android.content.Context;

public class MainActivity extends AppCompatActivity {

    WebView webView;
    private SwipeRefreshLayout swipeRefreshLayout;

    public Context context;

    private static final String TAG = MainActivity.class.getSimpleName();

    private static final int FILECHOOSER_RESULTCODE = 1;
    private ValueCallback&lt;Uri&gt; mUploadMessage;
    private Uri mCapturedImageURI = null;

    // the same for Android 5.0 methods only
    private ValueCallback&lt;Uri&#x5B;]&gt; mFilePathCallback;
    private String mCameraPhotoPath;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

       

        if (android.os.Build.VERSION.SDK_INT &gt;= 21) {
            Window window = this.getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
        }


        LoadWeb();



    }


    public void LoadWeb(){

        webView = (WebView) findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new ChromeClient());
        webView.getSettings().setAppCacheEnabled(true);
        webView.loadUrl(&quot;https://codeplaners.com/&quot;);
        webView.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl) {
                try {
                    webView.stopLoading();
                } catch (Exception e) {
                }

                if (webView.canGoBack()) {
                    webView.goBack();
                }

                webView.loadUrl(&quot;about:blank&quot;);
                AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
                alertDialog.setTitle(&quot;Error&quot;);
                alertDialog.setMessage(&quot;Check your internet connection and try again.&quot;);
                alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, &quot;Try Again&quot;, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                        startActivity(getIntent());
                    }
                });

                alertDialog.show();
                super.onReceivedError(webView, errorCode, description, failingUrl);
            }

        });

        //pull to refresh

        swipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipe);

        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                swipeRefreshLayout.setRefreshing(true);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        swipeRefreshLayout.setRefreshing(false);
                        webView.reload();
                    }
                },2000);
            }
        });

        swipeRefreshLayout.setColorSchemeColors(
                getResources().getColor(android.R.color.holo_blue_dark),
                getResources().getColor(android.R.color.holo_orange_dark),
                getResources().getColor(android.R.color.holo_green_dark),
                getResources().getColor(android.R.color.holo_red_dark)


        );

        //enable upload part

        webView.setWebChromeClient(new WebChromeClient() {


            // for Lollipop, all in one
            public boolean onShowFileChooser(
                    WebView webView, ValueCallback&lt;Uri&#x5B;]&gt; filePathCallback,
                    WebChromeClient.FileChooserParams fileChooserParams) {
                if (mFilePathCallback != null) {
                    mFilePathCallback.onReceiveValue(null);
                }
                mFilePathCallback = filePathCallback;

                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                if (takePictureIntent.resolveActivity(getPackageManager()) != null) {

                    // create the file where the photo should go
                    File photoFile = null;
                    try {
                        photoFile = createImageFile();
                        takePictureIntent.putExtra(&quot;PhotoPath&quot;, mCameraPhotoPath);
                    } catch (IOException ex) {
                        // Error occurred while creating the File
                        Log.e(TAG, &quot;Unable to create Image File&quot;, ex);
                    }

                    // continue only if the file was successfully created
                    if (photoFile != null) {
                        mCameraPhotoPath = &quot;file:&quot; + photoFile.getAbsolutePath();
                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                                Uri.fromFile(photoFile));
                    } else {
                        takePictureIntent = null;
                    }
                }

                Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
                contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
                contentSelectionIntent.setType(&quot;image/*&quot;);

                Intent&#x5B;] intentArray;
                if (takePictureIntent != null) {
                    intentArray = new Intent&#x5B;]{takePictureIntent};
                } else {
                    intentArray = new Intent&#x5B;0];
                }

                Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
                chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
                chooserIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.image_chooser));
                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

                startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);

                return true;
            }

            // creating image files (Lollipop only)
            private File createImageFile() throws IOException {

                File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), &quot;DirectoryNameHere&quot;);

                if (!imageStorageDir.exists()) {
                    imageStorageDir.mkdirs();
                }

                // create an image file name
                imageStorageDir = new File(imageStorageDir + File.separator + &quot;IMG_&quot; + String.valueOf(System.currentTimeMillis()) + &quot;.jpg&quot;);
                return imageStorageDir;
            }

            // openFileChooser for Android 3.0+
            public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType) {
                mUploadMessage = uploadMsg;

                try {
                    File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), &quot;DirectoryNameHere&quot;);

                    if (!imageStorageDir.exists()) {
                        imageStorageDir.mkdirs();
                    }

                    File file = new File(imageStorageDir + File.separator + &quot;IMG_&quot; + String.valueOf(System.currentTimeMillis()) + &quot;.jpg&quot;);

                    mCapturedImageURI = Uri.fromFile(file); // save to the private variable

                    final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
                    // captureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

                    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                    i.addCategory(Intent.CATEGORY_OPENABLE);
                    i.setType(&quot;image/*&quot;);

                    Intent chooserIntent = Intent.createChooser(i, getString(R.string.image_chooser));
                    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable&#x5B;]{captureIntent});

                    startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
                } catch (Exception e) {
                    Toast.makeText(getBaseContext(), &quot;Camera Exception:&quot; + e, Toast.LENGTH_LONG).show();
                }

            }

            // openFileChooser for Android &lt; 3.0
            public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg) {
                openFileChooser(uploadMsg, &quot;&quot;);
            }

            // openFileChooser for other Android versions
            /* may not work on KitKat due to lack of implementation of openFileChooser() or onShowFileChooser()
               https://code.google.com/p/android/issues/detail?id=62220
               however newer versions of KitKat fixed it on some devices */
            public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType, String capture) {
                openFileChooser(uploadMsg, acceptType);
            }



        });

    }



    private class ChromeClient extends WebChromeClient {
        private View mCustomView;
        private WebChromeClient.CustomViewCallback mCustomViewCallback;
        protected FrameLayout mFullscreenContainer;
        private int mOriginalOrientation;
        private int mOriginalSystemUiVisibility;

        ChromeClient() {}

        public Bitmap getDefaultVideoPoster()
        {
            if (mCustomView == null) {
                return null;
            }
            return BitmapFactory.decodeResource(getApplicationContext().getResources(), 2130837573);
        }

        public void onHideCustomView()
        {
            ((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomView);
            this.mCustomView = null;
            getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
            setRequestedOrientation(this.mOriginalOrientation);
            this.mCustomViewCallback.onCustomViewHidden();
            this.mCustomViewCallback = null;
        }

        public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
        {
            if (this.mCustomView != null)
            {
                onHideCustomView();
                return;
            }
            this.mCustomView = paramView;
            this.mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();
            this.mOriginalOrientation = getRequestedOrientation();
            this.mCustomViewCallback = paramCustomViewCallback;
            ((FrameLayout)getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
            getWindow().getDecorView().setSystemUiVisibility(3846 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        }




}

    // return here when file selected from camera or from SD Card
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        // code for all versions except of Lollipop
        if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.LOLLIPOP) {

            if (requestCode == FILECHOOSER_RESULTCODE) {
                if (null == this.mUploadMessage) {
                    return;
                }

                Uri result = null;

                try {
                    if (resultCode != RESULT_OK) {
                        result = null;
                    } else {
                        // retrieve from the private variable if the intent is null
                        result = data == null ? mCapturedImageURI : data.getData();
                    }
                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), &quot;activity :&quot; + e, Toast.LENGTH_LONG).show();
                }

                mUploadMessage.onReceiveValue(result);
                mUploadMessage = null;
            }

        } // end of code for all versions except of Lollipop

        // start of code for Lollipop only
        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {

            if (requestCode != FILECHOOSER_RESULTCODE || mFilePathCallback == null) {
                super.onActivityResult(requestCode, resultCode, data);
                return;
            }

            Uri&#x5B;] results = null;

            // check that the response is a good one
            if (resultCode == Activity.RESULT_OK) {
                if (data == null || data.getData() == null) {
                    // if there is not data, then we may have taken a photo
                    if (mCameraPhotoPath != null) {
                        results = new Uri&#x5B;]{Uri.parse(mCameraPhotoPath)};
                    }
                } else {
                    String dataString = data.getDataString();
                    if (dataString != null) {
                        results = new Uri&#x5B;]{Uri.parse(dataString)};
                    }
                }
            }

            mFilePathCallback.onReceiveValue(results);
            mFilePathCallback = null;

        } // end of code for Lollipop only


    }

    @Override
    public void onBackPressed(){

        if (webView.canGoBack()){
            webView.goBack();
        }else {
            finish();
        }
    }


}




</pre>
<p>Now open activity_splash.xml file from /res/layout path and write the code like as shown below</p>
<h3> activity_splash.xml </h3>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:background=&quot;@drawable/splash&quot;
    android:gravity=&quot;center&quot;
    android:orientation=&quot;vertical&quot;&gt;

    &lt;ImageView
        android:id=&quot;@+id/logo_id&quot;
        android:layout_width=&quot;180dp&quot;
        android:layout_height=&quot;180dp&quot;
        android:layout_centerInParent=&quot;true&quot;
        android:src=&quot;@drawable/applogo&quot; /&gt;

    &lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_below=&quot;@+id/logo_id&quot;
        android:layout_centerHorizontal=&quot;true&quot;
        android:text=&quot;Code Planers&quot;
        android:textColor=&quot;#fff&quot;
        android:textSize=&quot;30dp&quot; /&gt;

&lt;/RelativeLayout&gt;
</pre>
<p>Now open SplashActivity.java from \java\com.codeplaners path and write the code like as shown below</p>
<h3>SplashActivity.java</h3>
<pre class="brush: java; title: ; notranslate">
package com.codeplaners;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        if (android.os.Build.VERSION.SDK_INT &gt;= 21) {
            Window window = this.getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
        }

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {

                    Intent intent = new Intent(SplashActivity.this,MainActivity.class);
                    startActivity(intent);
                    finish();
            }
        }, 3000);
    }
}
</pre>
<p>Now open our application AndroidManifest.xml file in /manifests directory and write the code like as shown below</p>
<h3>AndroidManifest.xml</h3>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.codeplaners&quot;&gt;

    &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;&gt;&lt;/uses-permission&gt;
    &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;&gt;&lt;/uses-permission&gt;
    &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;&gt;&lt;/uses-permission&gt;
    &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
    &lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;
    &lt;uses-feature android:name=&quot;android.hardware.camera&quot; /&gt;

    &lt;application
        android:allowBackup=&quot;true&quot;
        android:icon=&quot;@drawable/applogo&quot;
        android:label=&quot;Code Planers&quot;
        android:roundIcon=&quot;@drawable/applogo&quot;
        android:supportsRtl=&quot;true&quot;
        android:usesCleartextTraffic=&quot;true&quot;
        android:hardwareAccelerated=&quot;true&quot;
        android:theme=&quot;@style/AppTheme&quot;&gt;
        &lt;activity android:name=&quot;.SplashActivity&quot;
            android:configChanges=&quot;keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize&quot;
            android:theme=&quot;@style/Theme.AppCompat.Light.NoActionBar&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity android:name=&quot;.MainActivity&quot; android:theme=&quot;@style/Theme.AppCompat.Light.NoActionBar&quot;&gt;&lt;/activity&gt;

    &lt;/application&gt;

&lt;/manifest&gt;
</pre>
<p><strong>Note:-</strong> Any problem contact my whatsapp 9829601023</p>
<p>The post <a rel="nofollow" href="https://codeplaners.com/android-studio-webview-app/">Android Studio Webview App</a> appeared first on <a rel="nofollow" href="https://codeplaners.com">Codeplaners</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codeplaners.com/android-studio-webview-app/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
