1

I have created a webview app of my site in Android Studio. Could someone please look into the code and solve the issue. This is my code:

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = findViewById(R.id.webView);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (url == null || url.startsWith("http://") || url.startsWith("https://")) return false;

                try {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    view.getContext().startActivity(intent);
                    return true;
                } catch (Exception e) {

                    return true;
                }
            }
        });
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setDomStorageEnabled(true);
        webView.loadUrl("https://xyz.in/admin_login.php");
    }

    public void onBackPressed(){
        if(webView.canGoBack()){
            webView.goBack();
        }else{
            super.onBackPressed();
        }
    }

When WhatsApp icon is clicked, it's opening in WhatsApp application,but when view location is clicked, the button is not responding. Please help on this issue.

Please find the attached image for your reference
enter image description here

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
vamshi g
  • 41
  • 8
  • Does this answer your question? [Launching Google Maps Directions via an intent on Android](https://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android) – Dmytro Rostopira Dec 21 '21 at 12:51
  • No..view location html link shall be similar to https://maps.app.goo.gl/HUo3dVhJbZ2oQ85J7 which shall be dynamically generated..so I could not understand how this can be implemented – vamshi g Dec 21 '21 at 12:53

0 Answers0