gps location update in background in iPhone app - ios6

I am creating an iPhone app,in which AI have to update the location during significant change.For that I have used "[locationManager startMonitoringSignificantLocationChanges]".
I have to update the location during the app is in background also.So I have given Required background Modes as "App registers for location update" in the info.plist .
My doubt is:
Is that necessary to give it in info.plist for background registration, when using startMonitoringSignificantLocationChanges?
If any body has idea then please help me...
Thanks in advance

The significant location changes will automatically start your app in the background without the required background modes key. Required background modes is only needed if you're continuously monitoring location like a street navigation turn by turn app.
EDIT: this is covered in the Location Awareness Programming Guide, it is worth reading:
The preferred option is to use the significant location change service
to wake your app at appropriate times to handle new events. However,
if your app needs to use the standard location service, you can
declare your app as needing background location services.
So if you are using significant location change service, it will be woken up and you don't need the background modes key. If you are using standard location service and must run in the background then you need the background modes key "location".

Related

How to make images resize as per client device size

I have a react app that has many image references ( tags <img src=... /> and css background:url(...)) type.
These images are hosted on Azure Storage.
To speed up my App loading time on various devices (desktops and mobile), I need to resize these images before they hit the client, ie, on the server somewhere.
So far, I can think of the following options:
Pick each image, and produce multiple versions of them for various standard device sizes. Then, pick up each <img src=... /> tag, and, using JS alter the image name, such that the right size of image gets served. This will not work with css.
Use Azure CDN to automatically resize images. I was hoping that resizing would happen automatically, as the CDN portal retrieves the user-agent from the device. Does anyone know if this is true?
Serve images through an Azure function, resizing them on the fly (as suggested here)
Can someone suggest other options they can think of, or a pros / con of the above.
Since you're using javascript, use the window tag. For browsers, the window tab measures the resolution of the browser and you can set the height and width of your image to window.innerHeight and window.innerWidth. There are multiple other ways to do this but this is the easiest and most optimised if your coding project needs to be efficient with the least lines of code necessary.
More info about the window object here : https://www.w3schools.com/js/js_window.asp
P.S. this is only a solution for desktop, for mobile you can use screen.width, screen.height. This might not work on desktop but on a macOS Big Sur device it works, I tried it (This might be because macOS Big Sur is like a mobile optimised interface given that you can even run iOS apps on it but we don't know unless we try). That might be a better option as it is most likely common across all your devices.
More info about the screen object here : https://www.tutorialrepublic.com/faq/how-to-detect-screen-resolution-with-javascript.php
On the off-chance that none of them are common across all of your target devices, try making a detector program with which you can detect the device type and store that in a variable. Then create 2 if statements saying
if(deviceType = iOS){
<img src=..., screen.width, screen.height/>
}else if(deviceType = Windows){
<img src=..., window.innerWidth, window.innerHeight/>
}
Obviously this code won't work but it's just there to show you the flow where you can sort of understand what I meant. You need to integrate it your own way but this was just a way to make it easier as many times people mention that my answers are not easy to understand, just as a safety measure.
The best part of these options is that instead of remade copies of the image itself, this will resize the one, which saves storage space and eliminates the chance of the user using an unexpected display output like a 49" Samsung Odyssey G9 monitor where the resolution is extremely far from what you might have expected and resized. This also means you don't have to create a separate file just to make image resizing code, just the one to detect the OS (not necessary if the screen object works) which would've already been done since this is Azure we're talking about and they always detect their user base.
If you have any queries, please reply back.
Good luck!

Getting Locations Best Practice

What are the best practices one needs to know when trying to get the most accurate location coordinates from a user.
How can I explicitly get location using the user's gps? How can I also ensure getting location using the network is accurate? I am asking because when I get location while I am home..by the time I get to the office, the location I get is still the same which isnt supposed to be so. Does it have to do with my listener?
Any help/code snippets will be appreciated.
Salam
Modern Android devices and all iOS devices don't use GPS as much as they use hybrid location. Hybrid location correlates all sensor information (including gps) to give a location as accurately and quickly as possible while reducing battery usage.
This is on by default in Codename One if you don't do anything like explicitly specifying that Google Play Services shouldn't be included or if you include google play services other than location (without including location via the build hint android.playService.location=true) this won't be used either. In those cases Android will fallback to use GPS which is slower.
You can read more about build hints here.
Notice that even then getting location takes time so make a request so you should use the getCurrentLocationSync() method or the location listener API to make sure you get a more accurate reading.

Show windows form over locked screen

I'm developing an application to run in background. This application is used to capture user’s activity on their system. Application is working very fine.
Now, I need to display a windows form over locked screen. Just like this:
Can any one help me! How can I show any windows form over locked screen?
Not possible, for security reasons no application should be shown when the screen is locked.
The only thing remotely similiar might be a Kiosk App:
Is the Windows.ApplicationModel.LockScreen namespace available for non-kiosk use?
There are a few different things here that are probably confusing things. unfortunately they are not very common scenarios so documentation is lacking.
You can use the Windows.ApplicationModel.LockScreen namespace for customising the display of the lock screen. This can be used to change the wallpaper or notification counts. It is probably the most common form of lock screen customization as it can be done by any app.
You can also use the functionality in this namespace to create an alternative lock screen. This could have different behaviour to the process of swipe up and enter password/PIN or Microsoft Hello face detection.
Creating such an app and distributing through the store requires extra permissions than 3rd party developers typically have.
"Kiosk mode" apps are created as apps that run above the lock screen. Such apps have no real connection to lock screen replacements but are related in their use of similar underlying elements of the OS.
In terms of what you are trying to achieve, it sounds like you should be able to do this by declaring the windows.lockScreen extension and then using LockApplicationHost to do the actual unlocking. As mentioned above the lack of a way for 3rd parties to distribute such apps through the store means there is a lack of documentation in this area but it should be possible.
One thing to take note of in such an app is an under even greater memory/resource constraints than a typical app and so you should keep this in mind during your planning and development.
I know this is an old question but for anyone still looking:
It is a security risk don't do it.
If you still want to do it this could help: SampleHardwareEventCredentialprovider
You will have to play with WinAPI and CredentialProviders but it is working demo and will show simple windows dialog with a button at lockscreen

Is it possible with Codename One to take a temporary photo?

Part of the process used in my app involves taking a photo (done with Capture.capturePhoto()). The photo is then resized to a small square of 200px and finally sent to a server.
I am able to delete the resized image with FileSystemStorage.delete() however the initial photo taken with Capture.capturePhoto() cannot be deleted because of the app being sand boxed (as described in this SO question )
This can be embarrassing for the user because these photos are polluting their gallery (the photos have no value for the user).
As deleting the initial photo is not possible, I was wondering if I could force the Captured photo to be stored in cache so that it gets automatically removed by the OS.
Maybe this question could be a solution for Android but I would prefer to avoid having to go native?
Consequently is it possible with Codename one to take a photo that will only be temporary and be deleted automatically ?
Thanks a lot,
Cheers
We try to delete the file automatically but since the OS takes the photo some platforms just stick it in the gallery and there isn't much we can do there. It's literally a matter of "this works on Android device A and fails on Android device B".
Apps like snapchat etc. don't use the device camera app but instead use the low level camera API's which are more complex and flaky. At this time we don't map these API's in Codename One so if you need something with lower level control you will need to use native interfaces. This is a non-trivial API though.

Global hotkey capture in VB.net

I want to have my app which is minimized to capture data selected in another app's window when the hot key is pressed. My app definitely doesn't have the focus. Additionally when the hot key is pressed I want to present a fading popup (Outlook style) so my app never gets focus.
At a minimum I want to capture the Window name, Process ID and the selected data. The app which has focus is not my application?
I know one option is to sniff the Clipboard, but are there any other solutions.
This is to audit the rate of data-entry in to another system of which I have no control. It is a mainframe emulation client program(attachmate aka java-hosted telnet with 3250 support).
The plan is
complete data entry in Application X.
Select a certain section of the screen in App X which is proof of data entry (transaction ID).
Press the Magic Hotkey, which then 'sends' the selection to my App.
From System.environment or system.Threading I can find the Windows logon.
Similiarly I can also capture the time.
All the data will be logged to SQL.
Once Complete show Outlook style pop up saying the data entry has been logged.
Any thoughts.
Hooking the keyboard/mouse & screen scraping is pretty much the limit of what you can do with an applet. Remember Java is compiled to bytecode and run in the JVM. Because of the nature of the JVM, portability, and security concerns, you don't really have access to anything inside of the applet. All you will probably see from .Net is a "SunAwtFrame" classed window with no children.
The focus thing is doable, just use SendMessage (& other) API's to do what you need in the background and as long as you don't change the focus it will remain as is (ie. running code does not require focus)
As far as the data extraction goes, its going to come down to whether or not you can pull that info from the screen using some (potentially hardcore) image processing. Applets are a sort of no-mans land (from within .Net atleast), there is no JavaWindow.Textbox.GetAStringForMePlease().
For the record, there is an exception, if you physically control the applet. In that case you can make a sort of applet shell to hook the guts of the applet.
It sounds like you need to set up a global keyboard hook to capture the hot key this code project article shows how to do that (in C# but it's not much different):
http://www.codeproject.com/KB/cs/globalhook.aspx
And then you could use the FindWindow API to find the other apps window, then find the control that contains the "transaction ID" and use the WM_GETTEXT message to copy the text from it.

Resources