-
Conteúdo Similar
-
Por jl_code
Não estou conseguindo configurar anúncios do admob no meu app eu segui os tutoriais que achei na internet consegui exibir os anúncios de teste mas quando eu coloco o meu id do admob no codigo ele não exibe os anuncios
-
Por alysson122010
Como faço para no meu web view mostrar so o link do meu site oq naofor do meu site abrir fora da web view.
Ja tentei varios tutorias que ta na net nenhum funciona.
Meu codigo da webview:
mWebView.setBackgroundColor( Color.parseColor("#1e2128")); mWebView.setWebViewClient(new Browser_home()); mWebView.setWebChromeClient(new MyChrome()); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setAppCacheEnabled(true); private void loadWebsite() { mWebView.loadUrl("https://www.baixarfilmetorrent.info/appyoufilmesnovo"); mWebView.setWebViewClient(new WebViewClient () { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { mWebView.loadUrl("file:///android_asset/erro.html"); } }); mInterstitialAd.show (); } -
Por gamesmax2
Pessoal sou novo com crianção de app android, este app e bastante simples utilizar webview.
Estou com um problema, queria abrir link externo que não seja do meu site no navegador do celular, meu código abrir todos os links externo no meu app.
exemplo quero que links externo sejam aberto no navegador e link como Youtube ou que utilizar algum app do celular seja aberto nesse app, segue meu codigo:
public class MainActivity extends AppCompatActivity { private WebView cash; @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); cash = findViewById(R.id.site); cash.getSettings().setJavaScriptEnabled(true); cash.setFocusable(true); cash.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); cash.getSettings().setAppCacheEnabled(true); cash.getSettings().setDomStorageEnabled(true); cash.setWebViewClient(new WebViewClient()); cash.setWebChromeClient(new Meusite()); cash.loadUrl("https://www.meusite.com.br/meu_site/"); } private class Meusite extends WebChromeClient { private View mCustomView; private WebChromeClient.CustomViewCallback mCustomViewCallback; protected FrameLayout mFullscreenContainer; private int mOriginalOrientation; private int mOriginalSystemUiVisibility; Meusite() {} public Bitmap getDefaultVideoPoster() { if (mCustomView == null) { return null; } return BitmapFactory.decodeResource(getApplicationContext().getResources(), 2130837573); } public void onHideCustomView() { ((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomView); this.mCustomView = null; getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility); setRequestedOrientation(this.mOriginalOrientation); this.mCustomViewCallback.onCustomViewHidden(); this.mCustomViewCallback = null; } public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback) { if (this.mCustomView != null) { onHideCustomView(); return; } this.mCustomView = paramView; this.mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility(); this.mOriginalOrientation = getRequestedOrientation(); this.mCustomViewCallback = paramCustomViewCallback; ((FrameLayout)getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1)); getWindow().getDecorView().setSystemUiVisibility(3846); } } @Override public void onBackPressed() { if (cash.canGoBack()) { cash.goBack(); } else { super.onBackPressed(); } } }
-
Por alysson122010
Olá galera, eu estou com um problema de abrir os links fora da webview.
Eu preciso que todos os links que nao seja o meu que esta rodando na webview abre fora dela pois meus anuncios tem que abrir fora.
Exemplo oq for meu link abre na webview, oq nao fora abre fora achei esse codigo na ne porem da erro no meu codigo:
Codigo da net:
https://pt.stackoverflow.com/questions/256177/questão-com-webview-abrir-mais-de-um-link-fora-do-app?rq=1
Meu codigo:
package com.example.cubomaster;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
public class MainActivity extends AppCompatActivity {
WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.setBackgroundColor(Color.parseColor("#1e2128"));
mWebView.setWebViewClient(new Browser_home());
mWebView.setWebChromeClient(new MyChrome());
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setAppCacheEnabled(true);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if(savedInstanceState==null){
mWebView.post(new Runnable() {
@Override
public void run() {
loadWebsite();
}
});
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
protected void onSaveInstanceState(Bundle outState )
{
super.onSaveInstanceState(outState);
mWebView.saveState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
mWebView.restoreState(savedInstanceState);
}
private void loadWebsite() {
mWebView.loadUrl("file:///android_asset/iniciar.html");
mWebView.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { mWebView.loadUrl("file:///android_asset/erro.html"); } });
}
class Browser_home extends WebViewClient {
Browser_home() {
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
setTitle(view.getTitle());
super.onPageFinished(view, url);
}
}
private class MyChrome extends WebChromeClient {
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout mFullscreenContainer;
private int mOriginalOrientation;
private int mOriginalSystemUiVisibility;
MyChrome() {}
public Bitmap getDefaultVideoPoster()
{
if (mCustomView == null) {
return null;
}
return BitmapFactory.decodeResource(getApplicationContext().getResources(), 2130837573);
}
public void onHideCustomView()
{
((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
setRequestedOrientation(this.mOriginalOrientation);
this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;
}
public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
{
if (this.mCustomView != null)
{
onHideCustomView();
return;
}
this.mCustomView = paramView;
this.mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();
this.mOriginalOrientation = getRequestedOrientation();
this.mCustomViewCallback = paramCustomViewCallback;
((FrameLayout)getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
getWindow().getDecorView().setSystemUiVisibility(3846);
}
}
}
-
Por luiz_paulo_andrade
Estou desenvolvendo um app com ionic que tem uma página webview dentro de um iframe, nessa webview existe um botão de download que funciona normalmente no browser, mas no android não funciona. Creio que o Android esteja bloqueando esse download, gostaria de saber como habilitar para que o download seja feito diretamente, como faz no browser.
-