In Android smart watch,If device is not interactive then watch will enter from Interactive Mode to Ambient Mode
In this Google link https://www.youtube.com/watch?v=Rwshwq_vI1s,they have explained only App StandBy and Doze mode
My Query here is Android Wear App flow will be from Interactive -> Ambient -> StandBy
or
Both App Standby and Ambient is Same?
Ambient Mode and App Standby are not the same, ambient mode allows your app to keep running on the foreground while staying visible to the user, and if your app is running on the foreground it will not enter to the stand by mode, see next paragraph:
App Standby allows the system to determine that an app is idle when the user is not actively using it. The system makes this determination when the user does not touch the app for a certain period of time and none of the following conditions applies:
The app has a process currently in the foreground (either as an activity or foreground service, or in use by another activity or
foreground service).
As you can see the ambient mode allows you to stay on the foreground thus not allowing to enter Stand By, it's worth noting that to be able to use the Ambient Mode the user has to enable the option Always on screen on the device.
Related
I have a Xamarin Forms app running in AVAudioSessionCategory = Playback mode and it works very nice, background audio is playing and even my timers keep running in the background, which is fine during playback.
How can I ensure that after a user has decided to stop playing audio (either by pressing a button inside of the app or by pressing the pause button on the lock screen) my app will go into a Suspended state and it won't drain the battery?
Is there a way to either force my app to go suspended or a way to verify whether it has?
As a side-note: Hooking the OnSleep method in App.xaml.cs is NOT sufficient because it is being called every time the app goes to the background even if it's playing audio, my timers are running, HTTP calls working, etc.
UPDATE:
Made an interesting discovery today:
Timers keep running running in the background when the app is started from Visual Studio in debug mode (over WiFi).
Timers seem to get suspended automatically by the OS (iOS) when the app enters background in Release mode.
My conclusion is: maybe the entire problem lies somewhere in the 'framework' that is added to the app by Xamarin to ensure communication between Visual Studio and the app? (Console, breakpoints, etc.) It would be a logical explanation.
I am developing an app in Xamarin Forms which will show thing live position of the user on a map and all the users having the app can track other users movement.
Right now the app is working fine in android. But in the iOS foreground, android background it stops after some time. It is not at all running in ios background when I put the app in the background it stops showing the location and stops fully.
Please share some idea to keep the app live in background and foreground mode for the whole day.
Generally speaking, mobile OSs will stop your apps, when they are in the background for some time. How strict the OSs are depends on the OS and the version. iOS has "always" been very strict about it, Android has been a bit more loose in older versions, but is quite restrictive in newer versions. Anyway, getting the location in background is quite a common use case and OSs are providing you options to do it nevertheless, if you ask them politely.
iOS
As of iOS 11, there is a distinction between updating the location when in use and when in background. The user can choose which one to grant and you'll have to handle it appropriately.
According to this guide you'll have to add the NSLocationAlways key to your Info.plist to contimue getting the location when in background.
Android
From the Android developer guide
In an effort to reduce power consumption, Android 8.0 (API level 26) limits how frequently background apps can retrieve the user's current location. Apps can receive location updates only a few times each hour.
Anyway
The system distinguishes between foreground and background apps.
An app is considered to be in the foreground if any of the following is true:
It has a visible activity, whether the activity is started or paused.
It has a foreground service.
...
According to this, you can create a foreground service, see here more about it
For this reason, foreground services must show a status bar notification with a priority of PRIORITY_LOW or higher, which helps ensure that the user is aware of what your app is doing.
So if you are starting a foreground service that is shown in notification bar, you should be able to retrieve updates, even if your apps main Activity is not in foreground.
I know iOS allows background tasks to run and, for example, continue to receive location updates, but is it possible to do this in a watch app?
In Xcode 9.3, I have configured my app for "background modes" and selected location, and that has created for the WatchKitExtension's an Info.plist, an entry for "Required background modes" of "App registers for location updates".
But my watch app still suspends when the screen turns off, and when it is in the dock.
The App Programming Guide for watchOS, however seems to exclude the possibility of running in the background to receive location updates as it only allows background processing for four classes of activity:
Background App Refresh Tasks. Use a WKApplicationRefreshBackgroundTask object to ...
Background Snapshot Refresh Tasks. Use a WKSnapshotRefreshBackgroundTask object to update ...
Background Watch Connectivity Tasks. Use a WKWatchConnectivityRefreshBackgroundTask object to receive data sent by your iOS app ...
Background NSURLSession Tasks. ...
Other posts to SO indicate it's not possible, but proving a negative is difficult, so I'm asking again:
Am I "flogging a dead horse" by trying to keep the watch App operating in the background for receiving location updates, or is Xcode is making promises that WatchOS won't deliver.
I'm delighted to be able to report that the horse I have been flogging for the past two weeks was not dead after all!
I have discovered an additional state in which my watch app will continue to run in the Background which does not require HKWorkoutSession.
These settings did the trick:
locationManager.allowsBackgroundLocationUpdates = true
and in watchKitExtension info.plist:
set UIBackgroundModes (Required background modes) to location (App registers for location updates)
And I repeat: I am NOT using healthKit
Now my app continues to run even when the screen is off and when the app is out of the Dock.
No, it is not possible.
As the WatchKit Programming Guide clearly states, WatchKit apps cannot use background execution except for 3 use cases:
Network operations using URLSession
Playing audio using WKAudioFilePlayer or WKAudioFileQueuePlayer
Run a workout using HKWorkoutSession
You cannot receive location updates in the background, according to the WatchKit Programming Guide, that should be done in the iOS app that is connected to your watchOS application.
I have an app that needs to perform some actions based on a TTimer.
When the app becomes inactive (in background), the timer stops working.
I could not find any relevant options for UIBackgroundModes.
How can I make a timer keeps running?
iOS pauses your app automatically shortly after it goes into the background. You need to let iOS know that you are going to continue operating in the background.
In Project > Options > Version Info you can add to the array key UIBackgroundModes the string values for the services that require to continue running in the background. This gets added to the info.plist for your project on iOS.
You can consult Apple's documentation on what these values do . . .
Value - Description
audio - The app plays audible content in the
background.
location - The app provides location-based information to
the user and requires the use of the standard location services (as
opposed to the significant change location service) to implement this
feature.
voip - The app provides Voice-over-IP services. Apps with this
key are automatically launched after system boot so that the app can
reestablish VoIP services. Apps with this key are also allowed to
play background audio.
fetch - The app requires new content from the
network on a regular basis. When it is convenient to do so, the
system launches or resumes the app in the background and gives it a
small amount of time to download any new content. This value is
supported in iOS 7.0 and later.
remote-notification - The app uses
remote notifications as a signal that there is new content available
for download. When a remote notification arrives, the system launches
or resumes the app in the background and gives it a small amount of
time to download the new content. This value is supported in iOS 7.0
and later.
newsstand-content - The app processes content that was
recently downloaded in the background using the Newsstand Kit
framework, so that the content is ready when the user wants it. This
value is supported in iOS 5.0 and later.
external-accessory - The app
communicates with an accessory that delivers data at regular
intervals. This value is supported in iOS 5.0 and later.
bluetooth-central - The app uses the CoreBluetooth framework to
communicate with a Bluetooth accessory while in the background. This
value is supported in iOS 5.0 and later.
bluetooth-peripheral - The app
uses the CoreBluetooth framework to communicate in peripheral mode
with a Bluetooth accessory. The system will alert the user to the
potential privacy implications of apps with this key set. See Best
Practices for Maintaining User Privacy for more information on
privacy. This value is supported in iOS 6.0 and later.
Notice you need to actually select the mode that matches what you are doing. You can't just select fetch when really all you are doing is background processing.
Is it possible to create an app the runs in the background? If so is there any samples out there for this?
In Windows Phone OS 7.1 you can actually use Background Agents now to perform tasks in the background.
from MSDN:
Scheduled Tasks and background agents allow an application to execute
code in the background, even when the application is not running in
the foreground. The different types of Scheduled Tasks are designed
for different types of background processing scenarios and therefore
have different behaviors and constraints.
You can use a PeriodicTask or ResourceIntensiveTasks. Read more about it in the MSDN article above.
And here's some sample code for you to integrate background agents into your existing app.
Sample Code: Background Agents in Mango
An application in the foreground can continue to run when the phone screen is locked(not background but...) by setting the PhoneApplicationService.ApplicationIdleDetectionMode property. By setting up your application to run when the phone screen is locked, a user is able to access the application quickly upon unlock. However, when your application runs under a locked screen, it could consume power outside of the user's control. For this reason, your application must minimize power usage when running under a locked screen
At the moment there is no way to create application that runs in background.
True multitasking for 3rd party Windows Phone 7 apps will come as an OS upgrade later this year. However, unless the app has to absolutely run in the background (like Pandora etc.), we as developers share some responsibility in making our apps feel at home with the rest of the OS.
Windows Phone OS offers app developers chances to save state of their applications to give the end users the feeling that it never stopped running; this is essentially the same as in other mobile platforms. As your app is being deactivated/closed, you have the option to "Tombstone" your state so that your users can come back to just where they left with BackStack navigation or future launches. Channel 9 had a nice set of demos & labs around tombstoning, found here.
Hope this helps!