preventing webview from opening browser

Discussion in 'Android App Developers' started by jazzmatazz2005, Sep 19, 2013.

  1. jazzmatazz2005

    jazzmatazz2005 New Member

    Joined:
    Sep 19, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    i just had an app made for me and i noticed that the webview launches the default browser.
    I've tried different thing but nothing works
    this is my web_activity java
    any help will be much appreciated.


    Code:
    package com.ctechs.audiomix;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    import com.rocdamic.com.R;
    
    public class Web_activity extends Activity {
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.web_activity);
    		
    		Intent intent = getIntent();
    		String url_to_open = intent.getExtras().getString("url_to_open");
    		
    		WebView wb_homepage = (WebView)findViewById(R.id.webView1);
    		wb_homepage.getSettings().setJavaScriptEnabled(true);
    		wb_homepage.loadUrl(url_to_open);
    		
    		
    	}
    
    }
     
  2. aber

    aber New Member

    Joined:
    Oct 24, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    When is the browser launched? When you click on links? In that case you can avoid it by assigning a WebViewClient to the WebView. Try to add this line:

    wb_homepage.setWebViewClient(new WebViewClient());
     
Search tags for this page

android open link in browser from webview

,

android webview opens browser

,

android webview opens link in browser

,

windows phone webview prevent open in blank