Implement interstitial ads in App

0

Can someone explain me in a brief tutorial on how to implement Admob interstitial ads in my app that is a simple browser.

The problem is that it is giving classes wrong, as I have no experience in java, I can not implement correctly. I need some help.

  

I'm trying to implement, from this example: tutorial

My code:

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (isOnline()) {
    Toast.makeText(getApplicationContext(), "Carregando", Toast.LENGTH_SHORT).show();

    //mWebView = (WebView) findViewById(R.id.webview);

    mWebView = (WebView) findViewById(R.id.webview);
    Uri uri = Uri.parse("http://xxxx.xx");//Link por defeito
    Intent intent = getIntent();
    if(intent.getAction() == Intent.ACTION_VIEW){
        uri = intent.getData();
    }
    mWebView.loadUrl(uri.toString());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSupportZoom(false);
    mWebView.setWebViewClient(new LinkWebViewClient());
    mWebView.requestFocusFromTouch();
    mWebView.setWebChromeClient(new WebChromeClient());
    }
else
[...]
}
private class LinkWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView webview, String url)
{
    if(isOnline()) {
        Toast.makeText(getApplicationContext(), "Loading", Toast.LENGTH_SHORT).show();
        webview.loadUrl(url);
        return true;
    }
    else
    {
        Toast.makeText(getApplicationContext(), "Sem conexão", Toast.LENGTH_SHORT).show();
        setContentView(R.layout.conexaofail);
        return false;
    }
}
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {

if((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack())
{
    if (isOnline()) {
        mWebView.goBack();
        return true;
    }
    else
    {
        setContentView(R.layout.conexaofail);
        return false;
    }
}
return super.onKeyDown(keyCode, event);
 }

Can anyone help me? I ask you to have a little patience with me, because I am a beginner and I want to learn.

    
asked by anonymous 09.11.2016 / 06:49

0 answers