import com.google.ads.AdRequest;
import com.google.ads.AdView;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Bitmap;
import android.view.Menu;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
public class Youtube extends Activity {
private WebView webView;
private ProgressBar progress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_youtube);
webView = (WebView) findViewById(R.id.webView4);
webView.setWebViewClient(new MyWebViewClient());
progress = (ProgressBar) findViewById(R.id.progressBar4);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.youtube.com/");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.ver_web, menu);
return true;
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
progress.setVisibility(View.GONE);
Youtube.this.progress.setProgress(100);
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
progress.setVisibility(View.VISIBLE);
Youtube.this.progress.setProgress(0);
super.onPageStarted(view, url, favicon);
}
}
public void setValue(int progress) {
this.progress.setProgress(progress);
}
@Override
public void onBackPressed() {
// Check if there's history
if (this.webView.canGoBack())
this.webView.goBack();
else
super.onBackPressed();
}
public void onCreate1(Bundle savedInstanceState) {
//Request an ad
AdView ad = (AdView) findViewById(R.id.adView);
ad.loadAd(new AdRequest());
}
}