Stop rotate on mobile device - android

This question has been asked many times on stackoverflow, but each time the correct answer was not working or not the correct one.
I am reopening this question, due to it's importance for mobile web device programmers.
I want to be able to stop rotation on a WEB SITE on a browser on one of the following OS: IOS and/or Android device or at least to modify the rotation to last landscape at least. So only landscape is permitted as a rotation.
I have tried many related questions with no solution:
Blocking device rotation on mobile web pages
Jquery mobile device rotation shrinks the screen
Any idea is welcome, thank you.
p.s.

#CommonsWare is right, you shouldn't just block the user from being able to rotate their device however they want. In fact, that's what makes mobile web apps so versatile. They encompass the principals of responsive design.
I know this isn't the answer you're really looking for but if you insist on doing so, take a look here: Block mobile web rotation with javascript.
I'm not sure but I'm guessing that still won't work simply because a web app isn't native to whatever device you're viewing it on and the app you're actually in is a browser eg Chrome, Safari, ect and those are almost certainly going to have different orientations enabled regardless of what your web app is doing.

Related

Web App seems to trigger mobile device colour temperature differently?

I have a very strange problem with my web app seemingly triggering a colour adjustment from the android device - normally colours are fairly vibrant, in the same Chromium based browser for other pages, but once switched to my web app, the screen's colour temperature turns cool, and saturation seems to be toned down, resulting in a dull grey looking page.
Other pages within my web app doesn't seem to trigger this colour profile change.
I cannot think of what possibly might be causing this. Is this solely something done by the device, and not possibly controlled by me, or is there something that can be done for the front-end code? This is a web app, and not a native app, so I can't access android APIs.
Is it possibly the mobile view of the website? I've seen websites have a poorly optimized mobile view, causing similar issues.

How to make app UI to work 100% same on all devices?

How to make sure that my App's popup or text appears exactly how I intended it to appear in all screen sizes? I want the aspect ratio of the popup to appear same and all the text that appears at the time of designing the popup to be same in all the devices.
Imagine an image who's size and content will be same across devices. But for some reason I can not use image here, the requirement is to use popup with text and butto. I dont want any screen to cut the popup or make the text of the popup disappear or turn to crap.
I can not do testing with one device at a time as I read on a site that there are over 10,000 android devices :|
Is there anyway or any tool part of Android Studio which can like quickly draw outlines of all the phones screen sizes to help me understand what aspect ratio is right for my popup?
Im a noob so my question may not make sense to you so please bear with me.
Unfortunately it's going to be nearly impossible to get things to appear 100% the same across all devices and browsers – Android runs on all sorts of devices and there are probably hundreds or thousands of different possible screen sizes, in addition to browser and operating system quirks. Start with identifying specific devices and screen sizes you wish to support. See Android's screen compatibility overview for some good information on this topic.
If possible look at user analytics to narrow down the most common devices, operating system versions, and browsers, then test against those.

Android WebView content layout different in Samsung's easy mode

I have a problem with Samsung's "Easy Mode".
Our C# application is developed using Android.Webkit.WebViewClient where we call some Web pages (HTML / CSS / JS) as a user interface. All views respond to all types of different devices. Also, all views work as expected running in "normal mode".
As soon as you activate the "Easy Mode" of Samsung devices, the webview appears to change the fontfactor and other important layout rules. Due to complicated controls but limited screen space, we are now forced to ensure that our views are not affected by easy mode or alternatively are resized to their optimal state.
I've already tried some viewport settings on the pages and some properties on the webview instance but nothing seems to work.
Does anyone have any idea how to force deactivation or how to detect and react on easy mode using web technologies or the webview instance?
I am definitely grateful for any help or advice!
Thanks!

show web site on Android lock screen [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm looking for a reliable way to let the Android user show a web site on the lock screen.
This could be done in principle in 3 ways:
Showing it on the native Android lock screen, but then they should be able to remove the native clock because my site is a world clock (you can see it at intelnav.50webs.com/world_time.html if you're interested). For all I know this can't be done.
Using a 3rd party custom lock screen that allows this. Unfortunately I couldn't find a good one, and I did some searching.
Writing a custom lock screen myself.
There are some suggestions and even sample projects for doing this, even some questions here on StackOverflow. But I'm not sure how reliable they are. There is no standard way of doing it, from what I found, since lock screen widgets were removed. But the proposed ways of building custom lock screens don't seem very reliable to me, from what I could judge from the comments I could find. So, one of my questions (sorry but the problem is somewhat complex), does anybody know of a sample project for a custom lock screen that actually has an app built by it and offered on Google Play and which actually works well on a wide range of devices ?
Could anybody help me with a suggestion for a reliable way to do what I want? Along the lines above?
Looks like I'm going to answer my own question. I'm not sure how many will be interested but you can never know.
Update sep 18: Now there is a short answer that wasn't available a year ago when I first answered it. Namely, my own WebLock app:
https://play.google.com/store/apps/details?id=com.simionescu.vlad.weblock
Below is my original answer that gives a general idea of how this can be done programmatically.
So I went into digging and looks like it can be done. It wasn't even as difficult as I feared it would be, though I wouldn't say it was very easy either.
The main points are as follows:
I wrote an app that basically puts the site on the native Android lock screen. (Actually, I already had an app and I added this functionality to it, but that's less important. The main thing is that my method requires writing an app.)
So I guess this falls somewhere between the cases 1 and 3 above. I do need an app, but it's not a full-fledged custom lock screen, as detailed below.
This of course means that the method is more general, it works with any app, not just for displaying a site.
Set FLAG_SHOW_WHEN_LOCKED for the Activity window, as shown for instance here:
How to make our own lock screen in android instead of default lock screen
But I only used this flag, the other 3 mentioned in the link I didn't need.
Launch the Activity (if it's not running already) and set it on top before the device screen goes off, that is on receipt of the ACTION_SCREEN_OFF event. This way, the app is always visible when the screen goes off so next time it starts, Android will put it in front of the lock screen. (At least if it's the standard one; from the documentation it looks like it should be working with a custom lock screen too but I didn't test it. I guess it depends on how that custom lock screen is written. Anyway, I don't necessarily want my site on a custom lock screen, if the user has one he probably won't want to see my site in front of it).
This also means that the site will appear in front if the device is switched off then on, even if it's not locked. Which is what I intended.
Automatically start the app at startup via the BOOT_COMPLETED event
Capture the standard back key (which is allowed, unlike for the home key) and make it act like the home key when it would otherwise terminate the app.
I intentionally let the home key act normally. This of course means that after pressing it (which is the way the user exits the app and enters the device) the lock screen underneath is shown. Otherwise I would have had to deal myself with password-protecting the device, which is in no way something I want to do. There are a few drawbacks with this approach but IMO they're small. For simplicity's sake I chose to do it like this.
Besides, this way my app remains reliable, which it wouldn't have if I had hijacked the home key, no matter which way.
As said, this means that this is no full-fledged custom lock screen, just a way of putting the site over the default lock screen.
(update nov. 18) There's one more important point. As described so far, such an app could have a security issue. I'm not an expert so I'm not sure if it really does, and if so how important it is, but you can never be too safe. If the user can go unchecked to any site, when on the lock screen, it means that if the phone is lost and a bad guy finds it, he could go to a site that has dangerous code that could unlock the device. I'm not sure if it really could be done but I wouldn't be surprised. So, one good advice for anybody who writes such an app would be to severely (but reasonably) restrict Web navigation while on the lock screen.
These are the main points, there are a few other implementation details but I'll leave them out for the moment.
All this looks pretty standard and reliable to me, given that it's all in the official Android documentation.
I tested it on my KitKat device, plus on 2 emulators, one also with KitKat on it, the other one with the latest and greatest. Everything seems to work fine. Including the case when the device / emulator is password protected.
So I just wrote the app and published it on Google play. It's here:
https://play.google.com/store/apps/details?id=com.a50webs.intelnav.worldtime
Which means that now there is at least an app on Google Play which has this feature. It remains to be seen how well it will behave. I'll probably have to make minor corrections in the coming weeks, but other than that it should be fine.
Also in the coming weeks, maybe a month or so, I plan to put another app that will do this generally with any site, at the user's request.
(update nov. 18) I finally wrote the app and put it on Google play. It took a little longer than planned but it's ready. It's here:
https://play.google.com/store/apps/details?id=com.simionescu.vlad.weblock&hl=en
As noted above, when on the lock screen, navigation is restricted to the same domain, so that if a bad guy finds the phone he cannot go to some malware site and unlock it.

How to keep a mobile device from switching off its display when showing a HTML page

is it possible to tell a mobile browser, that as long as a certain HTML page is displayed, the device should not turn off its screen?
I want to build something like Project Blinkenlights, but every participant brings his/her own pixel. To set each display to a certain color at a given point in time is managable, just let each one open a website that shows a blank page and changes the background to color the screen. I'd use JavaScript to link the devices and have them log into a control server. But having the pixels wink out because the devices go to sleep would somehow break the concept.
A dedicated app would be overkill, and not every passing onlooker would install an app anyway (at least I wouldn't).
Thanks in advance!
I'm pretty sure you can't do that without bundle your webview inside an app. And whatever is the OS. It's all about protecting the user (and his device battery)

Categories

Resources