What's new
DroidForums.net | Android Forum & News

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

preventing webview from opening browser

jazzmatazz2005

New Member
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);
		
		
	}

}
 
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());
 
Back
Top