How to load something in the background on blackberry? - blackberry

My app load some data from server and show it on the display. When app closed I want to check storage on the device and if not all data hadn't been loaded yet by user, then load data from server to device. Let me clarify I want do it when application not worked.
I read about background processes, but don't understand how it works and how to implement my feature via them. Can you describe how it should work in balckberry? All help would be appreciated

If you want the app to run in the background then you can override the onClose method in your main screen.
public boolean onClose() {
UiApplication.getUiApplication().requestBackground();
return true;
}

Related

Can anyone recommend the solution to solve ionic background issue in IOS

The app is able to send the HTTP POST successfully as long as it's in the foreground, but as soon as it goes to the background, the HTTP POST appears to stop. This is only an issue for iOS.
I tried the cordova-plugin-background-mode plugin but i don't want the audio part. is there any working example code using angular ng.IHttpService.
public GetEmployeeList(): ng.IPromise<Mobile.Models.Employee[]> {
return this.$http.get("~/api/Employee/EmployeeList")
.then((response: ng.IHttpPromiseCallbackArg<Mobile.Models.Employee[]>): Mobile.Models.Employee[] => {
return response.data;
});
}
if you just wanna keep your app alive when its in the background, surely the audio part is the easiest way.and to sove your particular issue, you need know how the "Background Model" works. https://upload-images.jianshu.io/upload_images/1501971-91e6c1164e13c3ee.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000
Being curious why dont you wanna use the normal way to salve the problem since there are so many tracks to use with the background model.

How to detect if UIAccessibilityRequestGuidedAccessSession is active on device, iOS swift?

I know how to put app into Single app mode programmatically, provided that Autonomous single app mode persimmon is granted by MDM server to App.
This link have detail description about how to lock app in single app mode too.
Code to Apply single app mode as below -
UIAccessibilityRequestGuidedAccessSession(true){
success in
completionBlock(success)
}
My Question/Requirement is, detect if app is running in Autonomous single single app mode or UIAccessibilityRequestGuidedAccessSession is enabled, if it's enabled then only show alert to user and ask if he wish to disable Single App mode.
I Tried to detect using UIAccessibilityIsGuidedAccessEnabled() but it's of no use, as return value is always false.
You can use BOOL UIAccessibilityIsGuidedAccessEnabled(void); to get that information.
Source#AppleDocs
You could also try to add UIGuidedAccessRestrictionDelegate and then react to
func UIGuidedAccessRestrictionStateForIdentifier(_ restrictionIdentifier: String) -> UIGuidedAccessRestrictionState
Remember though, guided access needs to be enabled by the user (triple tap home button). Not from the settings!
So #Akaino answer is right, but UIAccessibilityIsGuidedAccessEnabled method wasn't working as expected due to i used to apply code below on didFinishLaunchingWithOptions hence it wasn't working properly
UIAccessibilityRequestGuidedAccessSession(true){
success in
completionBlock(success)
}
When i applied same code above on viewDidLoad() method, UIAccessibilityIsGuidedAccessEnabled is working as expected.

Upload data in the background depending on the connectivity

I am having problems with understanding how to approach this problem as I am really new to xamarin and android both.
My problem is the following: I need to develop an android app, which takes photos of things and uploads them to a rest server. The confusing part is that the users have really poor connection, so I need to check the internet connection constantly and try to upload the photos when the internet is there. This check needs to be done in the background so the user wont notice any lag.
When the user clicks on "save" the app should save the photo and metadata to a local database or file (json or sqlite) and upload them when the internet is there.
I have tried many different approaches but failed due to lack of understanding how android threading and services work. (Bound service, Foregroundservice, SQLite)
As I dont have much time to research and test all the posibilities, I am asking you guys: How can I do this ?
Thanks for your understanding.
There is one nuget plugin Xam.Plugin.Connectivity for check internet continuously, and you can manage your code in event of this plugin.
For background, you need to create one background thread and you can call it from ConnectivityChanged event.
CrossConnectivity.Current.ConnectivityChanged += (object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e) =>
{
if(e.IsConnected){
//your code here for fetching data when internet connected.
//Create task for background process
Task.Run(() =>
{
//your code for background
}).ConfigureAwait(false);
}
}

Check if the network/connection is used in iOS

I'd like to know if there is any possibility to check if the application is using a network connection now to do something.
The application has a background service which is uploading data and the user may also press a button to download data. I do not want this user to be able to download, until the background process is finished.
Does the framework provide something to check if the connection is used?
I would suggest using BOOL property in your method where the background uploading codes are.
Then in your button's sender method, do something like this:
if (!upLoading)
{
// Your Downloading codes
}
else
{
// Show an alert here
}

which method calls on press of application icon on home screen when that application is running in background in blackberry?

does any one knows which method calls on pressing of application icon present on home screen when that application is running in background in blackberry?
I want to write code for page refreshment their? Does any one have idea please tell me?
Most likely UiApplication.activate() is what are looking for. The API says:
The system invokes this method when it brings this application to the foreground. By default, this method does nothing. Override this method to perform additional processing when being brought to the foreground.
If you are using Alternate entry point then
check that in your main method like this
public static void main(String[] args) {
if(args.length>0&&"alternate".equals(args[0])){
//call Background process here
}
else{
// call your gui application here
}
}

Resources