Breaking News

how to validate and create a google search with your URL



If you are creating an app for Android, and create a Web Browser app, then you have to create a google search in your browser app and also validate that URL.

so here's the code for validating your URL.
 private void ValidateUrl(String url) {  
     String prefix = "https://www.google.com/search?q=";  
   
     if(!url.startsWith("http://") && !url.startsWith("https://")&&  
     !url.endsWith(".com"))  
     {  
       url=prefix+url;  
     }  
     if(url.endsWith(".com") || url.endsWith(".as") || url.endsWith(".uk") || url.endsWith(".biz"))  
     {  
       if(!url.startsWith("http://") && !url.startsWith("https://"))  
       {  
         url = "https://"+url;  
       }  
     }  
     mywebview.loadUrl(url);  
   
   }  

Here, your URL is a value you get from your EditText.

and use this method where you want.

No comments