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");
}
Related
I want to load a login page with JavaScript but I couldn't get the JavaScript to load even though i made a setJavaScriptEnabled(true)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://itsikkerhed.talentlms.com/index");
}
Try to enable DomStorage: webView.getSettings().setDomStorageEnabled(true);
I am new to Android development and I am trying to make an app for my video website which has videos from YouTube.
The problem I am having right now is that the embedded iframe videos don't show the fullscreen button. I have been searching for a solution but have yet to find one that works for me.
mainActivity.java:
public class MainActivity extends Activity {
private WebView wv1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webView);
WebView myWebView = (WebView) findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
wv1=(WebView)findViewById(R.id.webView);
wv1.setWebChromeClient(new WebChromeClient() {
});
wv1.setWebViewClient(new MyBrowser());
wv1.loadUrl("http://m.youtube.com");
} .....
Thanks for any help.
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());
}
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");
}
I am trying to code in C# with DOT42. How do I navigate to an html inside my Assets folder. I have achieved the same wit Eclipse in java with the following Code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "http://www.google.com";
url="file:///android_asset/out/in/active_deals.html";
WebView webv = (WebView) findViewById(R.id.webview1);
WebSettings settings = webv.getSettings();
settings.setJavaScriptEnabled(true);
webv.setWebViewClient(new WebViewClient());
webv.loadUrl(url);
}
When I try to do the same in C# with DOT42, it says page not found:
protected override void OnCreate(Bundle savedInstance)
{
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainLayout);
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainLayout);
string url = "";
//url = "http://www.google.com";
url = "file:///Android_Asset/out/in/active_deals.html";
WebView myWebView = (WebView)FindViewById(R.Ids.webview1);
myWebView.SetWebViewClient(new WebViewClient());
myWebView.LoadUrl(url);
WebSettings webSettings = myWebView.GetSettings();
webSettings.SetJavaScriptEnabled(true);
}
I have tried naming the assets folder in lower case and upper case, both don't seem to work.
I have tried 'Android_Asset','android_asset','Asset' but none of it worked. It works with eclipse though.
When you add an embedded resource to your Visual Studio project, it will be converted to an asset in your APK with the full namespace name.
For example take this URL:
var url = "file:///android_asset/dot42AssetWebView.Resources.Index.htm";
It works fine for an embedded resource named Index.htm in a namespace "dot42AssertWebView.Resources".