For some reason, when using a Galaxy S3, I'm able to use the example demo from HTML5Rocks about Device Motion and get acceleration values from the phone's hardware.
Demo: http://www.html5rocks.com/en/tutorials/device/orientation/devicemotionsample.html
But I can't seem to get the code working on my own website. It should just be:
if((window.DeviceMotionEvent)||('listenForDeviceMovement'in window))
{window.addEventListener('devicemotion',deviceMotionHandler3,false);
function deviceMotionHandler3(eventData){var
acceleration=eventData.accelerationIncludingGravity;
...
Any ideas why this code would work for the website above, but not when I copy it into a blank html page?
Are you sure the device you're testing on supports detecting device motion?
Are you accessing the web page from a mobile device browser?
When I click on the link you provide from my PC I'm told that the device doesn't support the device motion event.
Related
I am working on an application which has a web view and a mobile view. For testing the mobile view I had used the chrome change to mobile display / tablet display option. But when I'm using the application in the mobile, there is a big difference. What am I missing ?
One of the differences in between web view and mobile view when we test is that of the user agent. If you want to get the mobile experience in testing on google chrome, you should not just change the view from chrome to mobile / tablet. But you should probably also find a way to change the user agent itself. Else you can open the same uri on the mobile phone browser. That way the user agent remains the same.
Also certain actions in the mobile browser will be different from that of web browser. In a browser in mobile view you can expect touch based actions whereas in the other case on web browser you can expect click based actions.
Read more on user agent here : https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
Also, you can use https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg to switch your user agent. We used that in a project although I do not know if it works well now.
Here's a reference on touch events: https://www.w3.org/TR/touch-events/#event-touchstart
I am doing a video call on the web, and I am trying to open the user's mobile flash when capture photo, is it anyway I can do this in javascript?
The flash I mentioned is the flashlight on mobile devices.
I had tried the media stream track method, but can only work for some devices only. cannot work on the iPhone.
thanks
Is there a way to get a log of all events that are generated on a given page? Printing events' names to console for example would be enough.
The reason is to know what happens on a particular user action (http://stackoverflow.com/questions/10071397/is-there-a-way-to-see-that-a-browser-window-is-minimized-while-the-user-is-switc).
If you're debugging Mobile Safari, run iOS >= 5.0 in the iOS Simulator and run iWebInspector. In the Timeline tab you should be able to see every event being fired by the browser after pressing the record button.
if you are using google chrome then you can connect your mobile device to your system using USB and in the google chrome try opening
chrome://inspect/#devices url.
Under Remote Target, the sites you opened in your mobile browser will be listed. You can click inspect to debug the site.
In the console use Monitor Events to track all the events.
for more info, you can check the Remote debug Android devices
Hi all sorry if this is repost. I really searched but can't find anything on it.
I always see this special ad when I use google services on my iphone or ipad. This little window animates out looking like a chat box. I can detect iOS device using user agent but how do I make the advert appear like google does? Specifically, try to open google maps.
I would like to use a window like this when users use iOS device to access my website. It is the most elegant way to tell iOS user about your app while not annoying them with some roadblock each time you try to access with iOS device.
Here is an image of what I'm talking about:
You can use this Javascript: http://cubiq.org/add-to-home-screen
I don't know whether this is your expectation, When your page has access from any iOS device, you wanted to bring up that dialog in webpage Right?..If That is the case then just retrieve the os info and make check there and do your presentation as you want.
Can mobile web apps run in the background? I'm mostly interest in iOS & Android.
Thanks!
Since this is a situation that changes almost daily, I'll post an updated answer. This applies to the recent releases of these browsers but may change tomorrow!
My music app is HTML5 and needs to run in the background. The support for that varies depending on mobile browser.
Safari on iOS: will continue to play one or two songs in the background
Native browser on Android: will play one song then stops
Firefox on Android: will stop when screen locks or browser loses focus or song ends
Dolphin on Android: plays in background but eventually stops
Opera on Android: Excellent background support! Javascript continues to run and music continues to play even when screen is off or Opera is sent to the background. Opera even puts a play/pause toggle into the notification page. Yay.
Here is a related SO question.
Nope, they can't. On Android you could conceivably install a different browser, but it's not possible on the stock one. #jgillman points out the exception of audio in iOS but that's the only exception I'm aware of.
iOS allows audio from a web app (Mobile Safari) to be played in the background. I don't know about other events though.
You can't run web app in the background. To enable most of the native features, you should develop native application.
At the time of this answer, Firefox mobile and Opera mobile for Android do allow javascript to run in the background, even with the screen locked.