Android: WebView - Open Links - android

I'm new with Android, so maybe someone can help me.
I have loaded an external URL in WebView.
I want that the links from my site http://www.domanin.com/about.php to open in WebView and the external link http://www.anotherdomanin.com/sample.php to open in default browser.
My code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyWeb = (WebView) findViewById(R.id.webView);
MyWeb.getSettings().setJavaScriptEnabled(true);
MyWeb.getSettings().setSaveFormData(true);
MyWeb.loadUrl("http://www.domanin.com");
}

Related

Why my html file is not displayed in android application?

When I build and run the application I see only black screen,The html file is using java script,video,audio file and images,I used these codes
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("file:///android_asset/aici/index.html");
}

Android Advance Webview Library - Webpage freezes while loading

I am loading html5 game from Advance webview library. One game is working fine but other game gets stuck after clicking on play button.
I opened the same game on chrome & other browsers (in Android), its working fine there. So the problem is not with the game but with my code.
I have attached the code below. Please check and let me know what is the issue?
Java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
setContentView(R.layout.activity_game);
Intent intent = getIntent();
String url = intent.getStringExtra(Constants.INTENT_URL_KEY);
isItemPurchased = intent.getBooleanExtra(Constants.INTENT_ITEM_PURCHASED, false);
AdvancedWebView mWebView = findViewById(R.id.webView);
mWebView.setListener(this, this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.loadUrl(url);
}

My first android app.. custom css

I'm trying to make an app with a webview of facebook.com, i want to load custom css but i don't know how. I searched on Google but found old tutorials and i read that it has changed in Android Studio 2.0
Here is my code:
private WebView myWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView)findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("https://www.facebook.com/");
myWebView.setWebViewClient(new WebViewClient());
}

Google maps link is opening in webview and not in app

I have made an android app in WebView. When I open a Google maps link, it's opening in WebView and not in the Google app. How can I fix this? I have searched on Google and on Stack Overflow but can't find the any solution.
Code:
public class FullscreenActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new myWebClient());
webView.loadUrl("http://www.mywebsite.nl/");
webView.setVerticalScrollBarEnabled(false);
}

WTAI does not work from WebView (Android)

Clicking on a link
<html>Click me to make a call</html>
in a WebView results in a "Page not found" error. Though the same link works just fine from the mobile browser. Any way to fix this?
EDIT:
String h = "<html>wtai</html>";
String g = "<html>tel</html>";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView web = (WebView) findViewById(R.id.webView1);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setPluginsEnabled(true);
web.loadData(h, "text/html", "utf-8");
}
This is the incorrect way of writing a tel WTAI link in Android.
Call us now!
is the correct way of writing this link.

Categories

Resources