How to get some information from WebView [duplicate] - android

This question already has answers here:
Android webview launches browser when calling loadurl
(11 answers)
Closed 6 years ago.
I must develop an Android Application that open certain urls in a Webview , but i have some problem :
When i try to open mobile site ( m.site.something.it ) an intent
start , wondering which browser i want use to open the web site.
I want force the opening of each site in a webview ( NO broweser ) .
I need to intercept all HttpRequest and HttpResponse all , how i can
do this ?
I'm developing for Android 6.0 , to post olds using deprecated method .
EDIT
Intent intent = getIntent();
String urlToLoad = intent.getStringExtra("url");
// webView.getSettings().setAppCacheEnabled(false);
WebView webview = (WebView) findViewById(R.id.wv);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
//THIS SHOULD FORCE OPEN SITE IN WV, BUT NOT WORK
webview.getSettings().setUserAgentString("Android");
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.loadUrl(urlToLoad);
***** EDIT 2 *****
Another problem is :
2. I need to intercept all HttpRequest and HttpResponse all , how i can
do this ?

Add this on your code:
myWebView.setWebViewClient(new WebViewClient());

Related

Android: WebView opens links in my app on my phone, but in browser on emulator

I have a WebView in my app where I load some internet address. I want when a user clicks on a link on that internet page, the default browser to be opened with the respective link. And I have implemented the following:
//set the addBanner
WebView wv = (WebView) findViewById(R.id.adBanner);
WebViewClient wvc = new WebViewClient(){
//open adds in new browser
#Override
public boolean shouldOverrideUrlLoading(WebView wv, String url) {
Intent i = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url));
wv.getContext().startActivity(i);
return true;
}
};
wv.getSettings().setJavaScriptEnabled(true);
wv.setWebViewClient(wvc);
wv.setWebChromeClient(new WebChromeClient()); //this was desperate attempt :)
wv.loadUrl(AdvertisementURL);
It works very well in emulator (Nexus 5, API 23; and some other emulators, too) - when I click on a link, new Browser activity is opened with the expected page on it. But on my phone (Android 4.2.2) - the links open in my app, and not in an external browser.
Why is this happening? And is there a way to fix it? Thanks a lot!

How to loaded survey form dynamically in android from url?

i need to know how to load Survey Form dynamically from my web url and show it in android.
For that you have to use WebView.
in your OnCreate() method use following code
WebView browser = (WebView) findViewById(R.id.webview);
browser.loadUrl("http://www.tutorialspoint.com");
Tutorial for implementing the complete solution : Open URL in WebView.

Web mobile app opening in browser but not in webview

I have problem using webview. When I am opening web mobile url in android browser it is opening perfectly but when i am using webView it is not rendering any view and stuck displaying a progress bar.
I am using below code:
myWebView = (WebView) findViewById(R.id.ctn_webview);
WebSettings webSetting = myWebView.getSettings();
webSetting.setJavaScriptEnabled(true);
webSetting.setDomStorageEnabled(true);
webSetting.setAppCacheEnabled(true);
webSetting.setBuiltInZoomControls(true);
webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
webSetting.setGeolocationDatabasePath("/data/data/<my-app-pkg>/databases");
webSetting.setGeolocationEnabled(true);
webSetting.setDatabasePath("/data/data/<my-app-pkg>/databases");
webSetting.setDatabaseEnabled(true);
webSetting.setAllowFileAccess(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl(myUrl);
Please note that the page is behind login credential so it redirects to many url in between to reach final page. The login page workes perfectly and after authentication i am redirected to final page where I see a round progress moving (image below). There it should render many buttons and form stuff.
Also when I am opening the same url in the browser in emulator it is working perfectly.
I dont know what I am missing. Please help.

Android Webview for videosteams?

I am using a webview to connect to an ip camera. It works when I need snapshots , but i get a white screen when I try to get videostreams. I tried .getPlugins as well. What could be the possible reason?
mWebView = (WebView) findViewById(R.id.webView1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://<ipaddress>/videostream.cgi?user=&pwd=");
you can call Browser activity and set specific URL by intent. Take a look here: Sending an Intent to browser to open specific URL

URL to open facebook app in android [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Open Facebook page from Android app?
I have a webview in my android app, and I would like to put a link in that opens the facebook app to my fanpage. In iOS you can say fb://... and it will open the facebook app. Is there a way to do it in android? I'm already overriding shouldOverrideUrlLoading, so I could intercept it and launch an intent if I need to.
You need to use Intents. Here's how to call the FB application (if it is installed):
Intent intent = new Intent();
intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth");
intent.putExtra("client_id", applicationId);
mAuthActivityCode = activityCode;
activity.startActivityForResult(intent, activityCode);
This code is taken from the Facebook API, which authorizes an action. Ajust to suit your needs. Code is Copyright 2010 Facebook, Inc., licensed under the Apache License, Version 2.0.
myWebView = (WebView) findViewById(R.id.webview); // Create an instance of WebView and set it to the layout component created with id webview in main.xml
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://m.facebook.com/pages/xxxxx-xxxxx-xxxxx/xxxxxxxxxx"); // Specify the URL to load when the application starts
//myWebView.loadUrl("file://sdcard/"); // Specify a local file to load when the application starts. Will only load file types WebView supports
myWebView.setWebViewClient(new WebViewKeep());
myWebView.setInitialScale(1); // Set the initial zoom scale
myWebView.getSettings().setBuiltInZoomControls(true); // Initialize zoom controls for your WebView component
myWebView.getSettings().setUseWideViewPort(true); // Initializes double-tap zoom control
Check if this works for you.

Categories

Resources