Mock GPS location and Chrome for Android - geolocation

I have a Trimble ProXT GNSS receiver that has Bluetooth and can connect to android using the Trimble GNSS Status app. The app outputs the location of the base unit and if I select the app as the mock location provider in developer options it works great in all native apps but if I try using a web app that's using the html5 geo location API it fails. My GIS data acquisition app is web based and I need this to work!

I ran into this same issue and was able to get some help from Trimble:
I'm assuming you're working on Android, as that's where we've seen this behavior as well. What you've noticed is an odd behavior characteristic of Google Chrome unfortunately. You'll find that if you use the Firefox browser (or several others) and visit the same maps.google.com, the location will display properly.
Inexplicably, the Chrome implementation of the Location API doesn't handle mock locations in all cases. We have an ongoing investigation into this on our end, but no formal resolution exists so far (aside from the non-Chrome browser workaround).

Using Trimble "GNSS status" app with an R2 and running into the same problems om both ipad+chrome and various android+chrome combinations while firefox and safari work ok.
for a simple test:
<DOCTYPE html>
<html>
<head>
<style>
body {
background: white;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
color: #000;
}
#media all and (max-width: 1000px) {
body { font-size: 200%;}
}
</style>
<script>
function init() {
var compass = document.getElementById('compass');
var lat = document.getElementById('lat');
var lon = document.getElementById('lon');
var acc = document.getElementById('acc');
var alt = document.getElementById('alt');
var altAcc = document.getElementById('altAcc');
var err = document.getElementById('err');
var heading = document.getElementById('heading');
var speed = document.getElementById('speed');
var timestamp = document.getElementById('timestamp');
if(window.DeviceOrientationEvent) {
window.addEventListener('deviceorientation', function(event) {
var alpha;
if(event.webkitCompassHeading) {
alpha = event.webkitCompassHeading;
}
else {
alpha = event.alpha;
}
compass.innerHTML = alpha;
}, false);
}
if(navigator.geolocation) {
var opts = {
enableHighAccuracy: true,
timeout: 6000,
maximumAge: 5000
};
navigator.geolocation.watchPosition(
updateLocation,
handleLocationError,
opts
);
}
}
function updateLocation(position) {
lat.innerHTML = position.coords.latitude;
lon.innerHTML = position.coords.longitude;
acc.innerHTML = position.coords.accuracy;
alt.innerHTML = position.coords.altitude;
altAcc.innerHTML = position.coords.altitudeAccuracy;
heading.innerHTML = position.coords.heading;
speed.innerHTML = position.coords.speed;
var t = new Date(position.timestamp).toString();
timestamp.innerHTML = t;
addMsg(t);
}
function handleLocationError(e){
var msg = e.code+': ';
switch (e.code) {
case error.PERMISSION_DENIED:
msg += 'Permission was denied';
break;
case error.POSITION_UNAVAILABLE:
msg +='Position is currently unavailable.';
break;
case error.PERMISSION_DENIED_TIMEOUT:
msg += 'User took to long to grant/deny permission.';
break;
case error.UNKNOWN_ERROR:
msg += 'An unknown error occurred.';
break;
}
addMsg(msg);
}
function addMsg(msg){
err.appendChild(document.createTextNode('message: '+ msg));
err.appendChild(document.createElement("br"));
}
</script>
</head>
<body onload="init()" >
<p>compass: <span id="compass"></span> deg</p>
<hr>
<p>lat: <span id="lat"></span> deg</p>
<p>lon: <span id="lon"></span> deg</p>
<p>acc: <span id="acc"></span> m</p>
<p>alt: <span id="alt"></span> m +msl</p>
<p>alt. acc: <span id="altAcc"></span> m</p>
<p>heading: <span id="heading"></span> deg</p>
<p>speed: <span id="speed"></span> m/s</p>
<p>timestamp: <span id="timestamp"></span></p>
<hr>
<p>messages:</p>
<div id="err"></div>
</body>
</html>

Related

Using google spreadsheets with mit2 app inventor

I want to use google spreadsheet with android. I Tried example program. I created new datasheet. I used example script code. I tried mit2 app program. This program is example program. I also used postman.
Postman show me error.
Postman error page.Postman connection error status 200 OK.
Postman error message is:
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="//ssl.gstatic.com/docs/script/images/favicon.ico">
<title>ERROR</title>
<style type="text/css" nonce="B6c+P2HTW+vClzlpE+anwg">body {background-color: #fff; margin: 0; padding: 0;}.errorMessage {font-family: Arial,sans-serif; font-size: 12pt; font-weight: bold; line-height: 150%; padding-top: 25px;}</style>
</head>
<body style="margin:20px">
<div>
<img alt="Google Apps Script" src="//ssl.gstatic.com/docs/script/images/logo.png">
</div>
<div style="text-align:center;font-family:monospace;margin:50px auto 0;max-width:600px">TypeError: Cannot read property 'getSheets' of null (line: 15, file: "denandroid")</div>
</body>
</html>
script code is :
function doGet(e) {
return ManageSheet(e);
}
function doPost(e) {
return ManageSheet(e);
}
function ManageSheet(e) {
//READ ALL RECORDS
if ( e.parameter.func == "ReadAll") {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0]; // Postman problem line.
var rg = sh.getDataRange().getValues();
var outString = '';
for(var row=0 ; row<rg.length ; ++row){
outString += rg[row].join(',') + '\n';
}
return ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT);
}
//DELETE SINGLE RECORD
else if (e.parameter.func == "Delete") {
var record = e.parameter.id;
var ss = SpreadsheetApp.getActive();
//var ss = SpreadsheetApp.openById(e.parameter.ID);
var sh = ss.getSheets()[0];
//var sh = ss.getSheetByName(e.parameter.SH);
sh.deleteRow(parseInt(record) + 1); //makes the correct row to delete (because of header row)
return ContentService.createTextOutput("Success, requested action completed");
}
}
postman says problem line in script code line 15. ( var sh = ss.getSheets()[0]; // Postman problem line)
Also I am using turkish language on google sheets. english name Sheet1 turkish language Sayfa1
I tried both names.
but unsuccess.
I am using this line for the connection spreadsheet.
https://script.google.com/macros/s/AKfycbyTt9oaz10WuKh0822hBncRoJZAw-D4hcGMwJwdy95l8H_mXfE/exec?ID=18NFZD7vZ-JySbbV7jiZMBpiBsoLJ4IQge9Wk9cL6Z4c&SH=Sheet1&func=ReadAll
Please help.
Thanks
Problem solved. The problem is the sharing problem. When sharing, it should be (Anyone, even anonymous). google always wanted me to sign in. When sharing (script code file) must be, In the 1st window, (me and gmail address) should be selected. (Anyone, even anonymous) should be selected in the 2nd window. sheet name not problem

onaudioprocess not called on ios11

I am trying to get audio capture from the microphone working on Safari on iOS11 after support was recently added
However, the onaudioprocess callback is never called. Here's an example page:
<html>
<body>
<button onclick="doIt()">DoIt</button>
<ul id="logMessages">
</ul>
<script>
function debug(msg) {
if (typeof msg !== 'undefined') {
var logList = document.getElementById('logMessages');
var newLogItem = document.createElement('li');
if (typeof msg === 'function') {
msg = Function.prototype.toString(msg);
} else if (typeof msg !== 'string') {
msg = JSON.stringify(msg);
}
var newLogText = document.createTextNode(msg);
newLogItem.appendChild(newLogText);
logList.appendChild(newLogItem);
}
}
function doIt() {
var handleSuccess = function (stream) {
var context = new AudioContext();
var input = context.createMediaStreamSource(stream)
var processor = context.createScriptProcessor(1024, 1, 1);
input.connect(processor);
processor.connect(context.destination);
processor.onaudioprocess = function (e) {
// Do something with the data, i.e Convert this to WAV
debug(e.inputBuffer);
};
};
navigator.mediaDevices.getUserMedia({audio: true, video: false})
.then(handleSuccess);
}
</script>
</body>
</html>
On most platforms, you will see items being added to the messages list as the onaudioprocess callback is called. However, on iOS, this callback is never called.
Is there something else that I should do to try and get it called on iOS 11 with Safari?
There are two problems. The main one is that Safari on iOS 11 seems to automatically suspend new AudioContext's that aren't created in response to a tap. You can resume() them, but only in response to a tap.
(Update: Chrome mobile also does this, and Chrome desktop will have the same limitation starting in version 70 / December 2018.)
So, you have to either create it before you get the MediaStream, or else get the user to tap again later.
The other issue with your code is that AudioContext is prefixed as webkitAudioContext in Safari.
Here's a working version:
<html>
<body>
<button onclick="beginAudioCapture()">Begin Audio Capture</button>
<script>
function beginAudioCapture() {
var AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();
var processor = context.createScriptProcessor(1024, 1, 1);
processor.connect(context.destination);
var handleSuccess = function (stream) {
var input = context.createMediaStreamSource(stream);
input.connect(processor);
var recievedAudio = false;
processor.onaudioprocess = function (e) {
// This will be called multiple times per second.
// The audio data will be in e.inputBuffer
if (!recievedAudio) {
recievedAudio = true;
console.log('got audio', e);
}
};
};
navigator.mediaDevices.getUserMedia({audio: true, video: false})
.then(handleSuccess);
}
</script>
</body>
</html>
(You can set the onaudioprocess callback sooner, but then you get empty buffers until the user approves of microphone access.)
Oh, and one other iOS bug to watch out for: the Safari on iPod touch (as of iOS 12.1.1) reports that it does not have a microphone (it does). So, getUserMedia will incorrectly reject with an Error: Invalid constraint if you ask for audio there.
FYI: I maintain the microphone-stream package on npm that does this for you and provides the audio in a Node.js-style ReadableStream. It includes this fix, if you or anyone else would prefer to use that over the raw code.
Tried it on iOS 11.0.1, and unfortunately this problem still isn't fixed.
As a workaround, I wonder if it makes sense to replace the ScriptProcessor with a function that takes the steam data from a buffet and then processes it every x milliseconds. But that's a big change to the functionality.
Just wondering... do you have the setting enabled in Safari settings? It comes enabled by default in iOS11, but maybe you just disabled it without noticing.

Azure Media Player on iOS devices

I'm streaming O365 videos using Azure Media Player in a web app that must be used only in mobile devices. It works with WP and Android, but the player stuck on iOS.
This is my code
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + bearer);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.GetAsync($"{url}/GetPlaybackUrl('1')");
var content = await response.Content.ReadAsStringAsync();
var firstVal = JsonConvert.DeserializeObject<VideoToken>(content);
response = await client.GetAsync($"{url}/GetStreamingKeyAccessToken");
content = await response.Content.ReadAsStringAsync();
var secondVal = JsonConvert.DeserializeObject<VideoToken>(content);
Client Side
<video id="newsVideoAMP" class="azuremediaplayer amp-default-skin amp-big-play-centered" tabindex="0"></video>
var initVideoPlayer = function (playbackUrl, streamingKeyAccessToken) {
try {
var myOptions = {
"nativeControlsForTouch": false,
controls: true,
autoplay: false,
techOrder: ["azureHtml5JS", "flashSS", "html5FairPlayHLS", "silverlightSS", "html5"],
logo: { enabled: false }
}
newsVideoPlayer = amp("newsVideoAMP", myOptions,
function () {
this.addEventListener(amp.eventName.error, function () {
window.alert('error');
console.log('Error: amp init');
var errorDetails = newsVideoPlayer.error();
window.alert(errorDetails);
var code = errorDetails.code;
var message = errorDetails.message;
$("#log").append("<li><span>code: " + code + " - detail: " + message + "</span></li>')");
});
});
newsVideoPlayer.src([
{
"src": playbackUrl,
"type": "application/vnd.ms-sstr+xml",
"protectionInfo": [
{
"type": "AES",
"authenticationToken": streamingKeyAccessToken
}
]
}]);
}
catch (err) {
console.log(err);
}
}
I think the issue is related to video encoding. So I tried to use GetPlaybackUrl('0') (and avoid the next token request), but the player stops to work on WP and Android and still not work on iOS.
The logger in callback function doesn't tell me some useful and I have also tried to change the tech order.
Is there a console to manage video encoding in order to avoid the AES algorithm and the decrypt token? Because this doc explain that iOS works with HTML5 tech will no token request. How can I solve? Thanks
I found a workaround to reproduce videos on iOS devices.
Instead of use REST API I put an iframe element in my page with the video embedded.
Like this (using MVC Razor):
var url = "{YourWebsiteUrl}/portals/hub/_layouts/15/VideoEmbedHost.aspx?chId={YourChannelId}&vId={YourVideoId}&width=853&height=480&autoPlay=false&showInfo=false";
<iframe width=853 height=480 id="videoframe" src="#url" allowfullscreen data-spresponsive style='position: absolute; top: 0; left: 0; right: 0; bottom: 0; height: 100%; max-width: 100%;'></iframe>
I get this code from the popup of "embed" menu in the video page of Office365 Video.
If somebody else knows another (and better) method, please let me know. Thanks

ReCAPTCHA v2 not working in IE Compability View

I'm trying to get recapatcha v2 working in my ASP MVC project. The client's computers have IE10/IE11 and shows all intranet pages in compatibility view which causes the recaptcha not to show as it is intended.
The problem is it rarely accepts my answer even though it's right. It just shows a new image, but every once in awhile I get it right. Anyone else experience this?
If you enable compability view for google.com in IE and visit the demo site you can try it out.
reCAPTCHA requires that compatibility view is not enabled in order to work, see:
https://support.google.com/recaptcha/?hl=en-GB#6223838
You are seeing reCaptcha's fallback. It seems that you have to get two correct answers in a row. It then gives you a response code that you copy and paste into a <textarea> element.
So what you are possibly experiencing is that you aren't getting two consecutive reCaptchas correct.
You can test the fallback recaptcha by adding the fallback=true parameter to the JavaScript resource:
<script src="https://www.google.com/recaptcha/api.js?fallback=true" async defer></script>
As explained by #Coulton recaptcha does not support IE compatibility mode.
reCaptcha uses a function in javascript named querySelectorAll, and querySelector. IE 11 in compatibility mode renders as IE 7.0, and IE 7.0 and below don't seem to have the functions querySelectorAll and querySelector and that is why it fails.
Now, I am using .net webforms so you may have to adapt it a little for MVC, but here it is:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="reCaptcha.aspx.cs" Inherits="reCaptcha" %>
<!DOCTYPE html>
<script type="text/javascript">
// this defines these functions if they don't exist.
if (!document.querySelectorAll) {
document.querySelectorAll = function (selectors) {
var style = document.createElement('style'), elements = [], element;
document.documentElement.firstChild.appendChild(style);
document._qsa = [];
style.styleSheet.cssText = selectors +
'{x-qsa:expression(document._qsa && document._qsa.push(this))}';
window.scrollBy(0, 0);
style.parentNode.removeChild(style);
while (document._qsa.length) {
element = document._qsa.shift();
element.style.removeAttribute('x-qsa');
elements.push(element);
}
document._qsa = null;
return elements;
};
}
if (!document.querySelector) {
document.querySelector = function (selectors) {
var elements = document.querySelectorAll(selectors);
return (elements.length) ? elements[0] : null;
};
}
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js' type="text/javascript"></script>
<script src='https://www.google.com/recaptcha/api.js' type="text/javascript"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/1.3.2/jquery.min.js' type="text/javascript"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>reCaptcha Test</title>
</head>
<body>
<h1>reCaptcha Test</h1>
<form id="frmResult" runat="server">
<div class="g-recaptcha" data-sitekey=""></div>
<script type="text/javascript">
function IeVersion() {
//Set defaults
var value = {
IsIE: false,
TrueVersion: 0,
ActingVersion: 0,
CompatibilityMode: false
};
//Try to find the Trident version number
var trident = navigator.userAgent.match(/Trident\/(\d+)/);
if (trident) {
value.IsIE = true;
//Convert from the Trident version number to the IE version number
value.TrueVersion = parseInt(trident[1], 10) + 4;
}
//Try to find the MSIE number
var msie = navigator.userAgent.match(/MSIE (\d+)/);
if (msie) {
value.IsIE = true;
//Find the IE version number from the user agent string
value.ActingVersion = parseInt(msie[1]);
} else {
//Must be IE 11 in "edge" mode
value.ActingVersion = value.TrueVersion;
}
//If we have both a Trident and MSIE version number, see if they're different
if (value.IsIE && value.TrueVersion > 0 && value.ActingVersion > 0) {
//In compatibility mode if the trident number doesn't match up with the MSIE number
value.CompatibilityMode = value.TrueVersion != value.ActingVersion;
}
return value;
}
var ie = IeVersion();
var reCaptchaApi = "";
$(document).ready(function () {
$('.g-recaptcha').each(function (index, obj) {
grecaptcha.render(obj, { 'sitekey': reCaptchaApi });
});
if (ie.CompatibilityMode) {
// loading it twice makes it load in compatibility mode.
$('.g-recaptcha').each(function (index, obj) {
grecaptcha.render(obj, { 'sitekey': reCaptchaApi });
});
}
});
</script>
</form>
</body>
</html>
This allows reCaptcha V-2 to load in compatibility mode.

Extracting Image Link from a rss feed on windows phone

I have a question.
How can I extract an url from an rss-feed?
The string which I need to extract is something like this:
><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="screen2" src="http://hereisthelink/screen2.png" alt="screen2" width="261" height="434" border="0" />
This is on the rss feed of my self hostet wordpress-blog, within the <content:encoded> section.
I want to fetch the first Image of an entry to get it together with the title (this works) in my ListBox.
However I tried many things to achieve this, but nothing works.
I am working with the Syndication.dll of Silverlight 3 to extract the feed items.
At the moment I am standing really in front of a wall for this to solve.
I am open to any suggestions.
You can use HTML Agility pack http://htmlagilitypack.codeplex.com/ There's a version for Windows Phone (HAPPhone in the trunk). After getting a Document from the content of the post you can get the first img element child of them.
var firstimage = document.DocumentNode.Descendants("img").FirstOrDefault();
Something like this should work for you:
var document = XDocument.Parse(html);
var items = new List<Item>();
var channel = (XContainer) document.Root.FirstNode;
foreach (XElement item in channel.Nodes())
{
try
{
var item = new Item();
var nodes = item.Nodes().ToArray();
foreach (XElement keyValue in nodes)
{
var value = keyValue.Value.Trim('\r', '\t', '\n', ' ').ToLower();
switch (keyValue.Name.LocalName)
{
case "title": item.Title = value; break;
case "content:encoded": item.Content = value; break;
// TODO: add more fields
}
}
var match = Regex.Match(item.Content, "<img(.*?) src=\"(.*?)\"[^>]*>");
item.FirstImageUrl = match.Groups[2].Value;
}
catch
{
// TODO: handle exception
}
}
return items;
You only have to finish the switch statement and create the Item class.

Resources