Issue with html Geo location - android

I've got some issue with geo location in html.
I'm developing a android app, one of the pages is webview this one loads a url I've been created.
The problem is: it ask to allow location but how to set it so always is allowed ??
Because that is not possible in Android app to request.
This is the code:
<iframe id="map_iframe" style="border:none; margin:0px; padding:0px; width:100%; height:150%;" src="https://url.com" allow="geolocation; microphone; camera; midi *; marginheight="0" marginwidth="0" frameborder="0" border="0"></iframe>

I've got some issue with geo location in html.
I'm developing an Android app, one of the pages is webview this one loads a url I've created.
The problem is: it ask to allow location but how to set it so always is allowed?
Because that is not possible in Android app to request.
This is the code:
style="border:none; margin:0px; padding:0px; width:100%; height:150%;" src="https://url.com" allow="geolocation; microphone; camera; midi *; marginheight="0" marginwidth="0" frameborder="0" border="0">

Related

Android App to read write files in Google Drive

I have a Google App Script web application through which users can accomplish the following tasks
Read/Write Spreadsheets in my G-Suite Drive
Read/Write CSV files in my G-Suite Drive
Read/Write Script, User and Document properties of the Project
The web app permission is set to execute as Me.
I intend to create an Android Application to achieve all the above tasks. Is it possible to build one? If yes please provide some pointers, sample codes or any tutorial to start with.
Here are some excellent resources:
"Please provide some pointers"
I would recommend using this as a basis for all projects to be deployed as web apps, although this might be better suited to be a add on, I'm just going to go with it
make three more files (you start with one, code.gs, when you start) all html
a) html, Index.html This is your main html code
b) html, CSS.html This is your CSS (cascading style sheet) file
c) html, javascript.html This is going to help you string them together
copy and past the following removing what is there when you created the file
code.gs
function doGet() {
return HtmlService.createTemplateFromFile('index')
.evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include('css'); ?>
</head>
<body>
<?!= include('javascript'); ?>
</body>
</html>
css.html
<style>
/* CSS reset */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
margin:0;
padding:0;
}
html, body {
margin: 0;
padding: 0;
}
body {
font-family: 'Roboto', sans-serif;
font-weight: 100;
}
fieldset {
border: 1px solid white;
color: white;
text-align: center;
width: 200px;
}
legend {
padding: 0 10px;
}
</style>
javascript.html
<!DOCTYPE html>
<script>
window.addEventListener('load', function() {
console.log('Page is loaded');
});
</script>
"Please provide some sample code"
You obviously have the code above, but try google apps documentation here. I prefer not to use this as a tutorial, accept for google app script only features. Its not my favorite but is your best bet for written code examples specific to google app script. Also remember you can always go to the google-apps-script tag in stack overflow too!
"Please provide any tutorial to start with"
Most people would say w3 schools, and while I like w3 schools I recommend as a tutorial if you prefer to just google stuff to learn, not follow examples and try it out. If that's not you, I recommend you use w3 schools as a reference rather than a tutorial. As for a tutorial, I recommend codecadamy (the lessons are free, the quizzes and projects are not) as the number 1 tutorial.
Edit: Also check out google app script documentation for tutorials more specific for this question like here

iframe "File not found" error

I don't know much about html but there is a small issue and I am unable to find its solution.
This is the iframe that I want to display on static html page:
<!DOCTYPE html>
<html>
<body>
<iframe style="width:120px;height:240px; padding-right:50px; padding-bottom:50px" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ac&ref=qf_sp_asin_til&ad_type=product_link&tracking_id=qstore51214-20&marketplace=amazon&region=US&placement=0553496670&asins=0553496670&linkId=4f9912a00b832e2f8bcb5a9b187511cf&show_border=true&link_opens_in_new_window=true&price_color=333333&title_color=0066c0&bg_color=ffffff">
</iframe>
</body>
</html>
When I add this to html and try to open html page, I get the error:
"File not found".
But when I add this iframe to any live html editor it work perfectly and show the link.
Actually I want to display this iframe in Webview in my Andriod application.
My android code is:
mWebViewTopSeller = (WebView) findViewById(R.id.webViewTopSeller);
mWebViewTopSeller.setWebChromeClient(new WebChromeClient());
mWebViewTopSeller.setWebViewClient(new WebViewClient());
mWebViewTopSeller.getSettings().setJavaScriptEnabled(true);
mWebViewTopSeller.loadUrl("file:///android_asset/TopSeller.html");
Please help. Thanks!
When embedding this iframe, it returns an error:
SEC7111: HTTPS security is compromised by https://ws-na...
So it may have something to do with the browser's mixed-content/same-origin policy.
Possible src values are an absolute URL that points to another web site (like src="http://www.example.com/default.htm")
or an relative URL that points to a file within a web site (like src="default.htm" I think your src path is wrong.

Phonegap crushes on external page load

I'm in the very beginning with phonegap (2.2.0). In my index.html I have a iframe to load a external facebook page, it's just a dummy page, and most of the cases it loads pretty well. But when it fails do load (didn't get it why) the entire application crushes. The iframe is loading after all the other itens of the page are loaded and when it timeouts, app crushes. I firstr tried the src on the iframe tag as well with the same result (changed to better test)
The url loading:
jQuery("#facebookIframe").attr({"src" : "https://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fcocacola&colorscheme=light&show_faces=true&border_color=%23fff&stream=false&header=false&height=186"})
The iframe
<div id="facebookFrame" style="text-align: center; width: 99%;">
<iframe id="facebookIframe" style="border: none; width: 90%;" ></iframe>
</div>
For the record, I'm using android and the error messages I get are:
"The connection to the server was unsuccessful." and TIMEOUT ERROR!
Thanks

Unable to switch to IFrame using Android WebDriver

I was wondering if someone could point me to what I am doing wrong exactly. I am trying to access an iframe using Android WebDriver. The iframe opens up when I click on a Sign in link on the home page. Below is a snippet of the src code that has the iframe id that I am trying to access-
<div class="dialog" style="background-color: rgb(232, 235, 238); color: rgb(51, 51, 51);">
<iframe id="registration-dialog-frame" scrolling="no" frameborder="0" src="http://test.com" border="0" allowtransparency="true" style="width: 235px;">
<html>
</iframe>
<span id="signin-cancel" class="cancelButton">Cancel</span>
I wait till the iframe opens up, check if the frame id is present and then use switchTo() to switch to that iframe like this
driver.switchTo().frame("registration-dialog-frame");
I get a
org.openqa.selenium.WebDriverException: Error: {"message":"Cannot read property 'document' of undefined"}
When I try this
driver.switchTo().frame(driver.findElement(By.id("registration-dialog-frame")));
I get a
org.openqa.selenium.WebDriverException: java.util.ArrayList cannot be cast to org.openqa.selenium.android.library.DomWindow
Is this a Android WebDriver thing? Has anyone else come across this similar kind of errors when switching to iframe? Does anyone know how I can do this?
Check the number of frames present in that page by looking at code and use index to switch into that particular frame as shown below.
driver.switchTo().frame(frameindex);
Ex: To Switch to the first frame, use below line.
driver.switchTo().frame(0);

Load web-application into a webview using local paths for images stored in the application

I want to be able to create an app that uses WebView to request a url
from an external web application which returns html and css that
references images that are assets within the actual application. The
idea is basically to speed up everything so that images never have to
be downloaded.
Here is a simplified example:
Server HTML:
<html>
<head>
<style>
#myImage { background-image: url("file:///android_asset/myImage.jpg"; width: 50px; height: 50px;}
</style>
</head>
<body>
<div id="myImage"></div>
</body>
</html>
So, is there any way to be able to do this? My main goal is to just have the application request all the HTML from a server, but be able to map the image urls to local resources within the application.
Thanks in advance,
Leon
Why not to load all HTML from application side? If you bother that this web page will have no access to network - use WebView.loadDataWithBaseUrl method.
For embed images into a web page you can use data:URI scheme: http://en.wikipedia.org/wiki/Data_URI_scheme
Also you can map your application images even if you are page is loaded remotely. You can use WebView.loadUrl("javascript:....") to "send" images data via JavaScript code (also using data:URI scheme).
EDIT.
Firstly, at HTML side your example with embedded images will look something like this:
<html>
<head>
<style>
#myImage { background-image: url('data:image/png;base64,iVBORw0KG.....'); width: 50px; height: 50px;}
</style>
</head>
<body>
<div id="myImage"></div>
</body>
</html>
When, if you want to store this page at the application side, you can store it somewhere (string resource, asset folder) and when get it.
String pageResource = // get it somehow
WebView myWebView;
myWebView.loadDataWithBaseUrl(
"http://my.site.com", // The base url
pageResource, // page content to load...
"text/html", // it's MIME type...
"UTF-8", // and encoding
"http://my.site.com/page.html");
Now the WebView has loaded your page. It is loaded from local resources but from WebView point of view it is like it is loaded from the network. It has access to network resources and JavaScript code working here as well (this is the main difference between loadData and loadDataWithBaseUrl).

Categories

Resources