4

I have a WebView app that I want to behave like this:

The user can follow any link and the new page is opened inside the same WebView, except if the target is YouTube in which case I want two possible scenarios:

  1. Open the YouTube Android app to view the video
  2. Open the standard browser to view the video.

My main activity is as follows:

package com.prgguru.android;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.webkit.WebView;


@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
     WebView browser;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        browser=(WebView)findViewById(R.id.webkit);     
        browser.getSettings().setJavaScriptEnabled(true);
        browser.getSettings().setDefaultFontSize(20);
        browser.loadUrl("http://exo-agency.com/funnytube/");   
    }
}

Thanks in advance.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
user2180451
  • 41
  • 1
  • 3
  • Your code example shows how you've created a WebView, but it would be helpful to include the results of any research you've done into solving the specific problem at hand. For example, have you found anything promising in the Android WebView documentation? – Martin Atkins Mar 17 '13 at 23:13

0 Answers0