Android Webview Authentication via Javascript prompt - javascript

I was working on creating an app on Android which basically is a simple webview of a website. At a certain point in the website, on clicking a link it gives a JS prompt asking for authentication credentials. I am having problems in displaying the JS prompt in my web view.
public class IASCActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView myWebView = (WebView) this.findViewById(R.id.webview);
//WebSettings webSettings = myWebView.getSettings();
//webSettings.setJavaScriptEnabled(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebChromeClient(new WebChromeClient());
myWebView.loadUrl("http://iasc.hsutx.edu/");
myWebView.setWebViewClient(new WebViewClient());
}
}

Related

Redirect to specific url if page viewed from android by detecting it's package name from website (html or javascript)?

Is it possible Redirect to specific url if page viewed from android by detecting it's package name (or another identificator information) from website (html or javascript)?
I think what you are looking is this meta tags.
I think this idea is impossible if you brows your web page from external browser (like google chrome).
So I suggest to brows the web page in a webview inside your android application and make your code listen for this webview by extend WebViewClient and call onPageFinished() :
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
}
});
In the web app you can make a specific page for redirecting (for example www.your_website.com/redirecting.html) , and make the app do what you want when surf this link :
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
if(url == "www.your_website.com/redirecting.html"){
//do what you want...
}
}
});

How to make android app for existing dynamic website

I want to develop an android app like olx, and quikr for one of my website, Fusion120. Front end of website is in html, css, javascript, jquery and back end uses php and sql server. I don't know where and how to start, please Gide me.
you need to can webview in android app when icon is click
public class WebViewActivity extends Activity {
private WebView webView;
WebView mwebview;
ProgressDialog barProgressDialog;
ConnectionDetector cd;
Boolean status;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
String myurl = "http://www.fusion120.com";
webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(myurl);
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
PhoneGap SDK is very useful to make app using HTML, jquery-mobile and web-services. You can go for it and have a look at the tutorials. Very basic knowledge of android is enough to make your site in Android.
database which you use in the website can be exposed to other mobile devices and other applications via web services or REST services.
service development is depend on which technology, program language you going to use etc...
try this link
http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/
i hope your work is done by this answer

Unable to load a specific webpage on Android webview

I am unable to see the following webpage in an Android webview: https://play.ericsson.net It should re-direct to a login page, can anyone produce a success case for opening the above webpage in an android webview?
FYI I'm activating javascript and setting WebViewClient.
Am I missing something?
Did you try this? Https sites are troublesome on android.
mWebView.setWebViewClient(new WebViewClient() {
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
}

Google Analytics not working in Android webviews [duplicate]

I have a simple native Android app that is a webview of a website, effectively to make the mobile-ready site native-like if you will. The website already has Google Analytics installed.
What might be a good way to track which visitors are using the app?
I could adding Android Native App Tracking, but I presume that would
double track the users. Unless it's smart enough to connect the visits?
I could pass custom get variable to the site that maybe adds a custom
attribute to the tracking for native app users. But that doesn't
sound very clean.
What might be best for tracking? I feel there's got to be an obvious answer I'm missing.
that should help you:
Now getting back to the Analytics tracking of this web app, I used the code provided by Google here.
So the code becomes somewhat like this.
public class myWebApp extends Activity{
Webview mWebview;
GoogleAnalyticsTracker tracker;
protected void onCreate(Bundle savedInstanceState) {
tracker = GoogleAnalyticsTracker.getInstance();
// Start the tracker in manual dispatch mode. The following UA-xxxxxxx-x code must be replaced by //your web property ID.
tracker.startNewSession("UA-xxxxxxx-x", this);
mWebview = new WebView(this);
mWebview .setWebViewClient(new myWebViewClient());
mWebview .loadUrl("file:///android_asset/www/index.html");
private class myWebViewClient extends WebViewClient
{
//After the user visits a particular page, send the tracking notification to GoogleAnalytics.
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
tracker.trackPageView( mWebview.getUrl());
tracker.dispatch();
}
}
}
http://www.the4thdimension.net/2011/11/using-google-analytics-with-html5-or.html
And in stats of google analytics you should get some info at least about operating system android.

Android webview limited loading

i hope someoune can help me with this problem that gived me headeakes.
package org.example.browserview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class BrowserView extends Activity {
private WebView webView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.web_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://m.test.com");
}
}
It works but the problem i have is that i dont want to load all the page into my webkit, i want to load the page without the header of the html. (so i need to hide the header somehow)
The html header id i've set it to "header" and i used jquery in the html page. So all i have to do and i dont know is how to make a javascript command $('header').hide(); or document.getElementById('header').hide(); before i insert the page into android application.
So in this way i will get the page into android application without the header.
I guess you can call JavaScript with loadUrl("javascript:...;") after loadUrl("http://..."):
webView.loadUrl("javascript:$('header').hide();");
or
webView.loadUrl("javascript:document.getElementById('header').style.display='none';");
See also: http://lexandera.com/2009/01/injecting-javascript-into-a-webview/

Categories

Resources