UiApplication.activate() method called post app install on some BlackBerry Bolds. Why? - blackberry

I'm having troubles with the UiApplication.activate() method firing post-app-installation (OTA install).
I have:
public class PlayerApp extends UiApplication
public PlayerApp() {
new Thread(this).start();
}
public void run() { ... }
public void activate() { ... }
I'm having troubles with the activate() method. It's firing to early, it's firing post--installation when it shouldn't (I thought it should fire when the application is selected by the user from the menu). What makes it worse it's not occuring on all Bolds. The BB is meant to ask for a reboot, but activate() is firing before this point and plays hell with the UI.
Questions. When does activate() really fire? Should activate() be firing post-install anyway? Is there a way to handle activate() firing post-installation? Is this a bug in the rim apis?
Note: The problem appears on BB Bold 4.6.0.144/4.0.0.143 and thus far I've not been able to replicate the issue on 4.6.0.282/4.0.0.235.
Edit: Installation flow: OTA link > Download > Install > 'Yes' to 'Trust application status' > AutoStart app > Trouble starts here.

According to the API docs activate():
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.
So, I suspect after OTA install the user is given the option of running the app which, when accepted, brings the app to the foreground. It is difficult to be certain without seeing your startup code. If your app is configured to autostart, then it will be "autostarted" after install. If this casues the UI to be instantiated and brought to the foreground, the activate will be called at that time.

Related

Xamarin/MAUI iOS best approach to update app in background every 15 minutes?

I would like that my app could make a small api call to a server so that it checks if there is an update, the data is very small and it shouldn't require that much time to execute, if it fails, it's not a problem that will try the next 15 minutes. It will show a generic notification to the user, so that the real data update will be done when the app is loaded. I know how to do the notification part, but not the api call.
The app should do this call when it's in the background and even if the user closes it from the multitasking UI and auto start when the device is turned on but the app hasn't been opened once yet.
In Android you can archieve this with the AlarmManager but from what I understand there is no way for this on iOS other than remote push notifications?
In the iOS part, you can achieve it with Backgrounding with Tasks​. However, iOS backgrounding is much more restrictive than on Android as there are only a few specific tasks that apps are allowed to do in the background (things like VOIP, audio, location, etc.). You can use a UIApplication background task to delay that suspension for a few minutes, but you can’t delay it indefinitely.
public override void DidEnterBackground (UIApplication application) {
nint taskID = UIApplication.SharedApplication.BeginBackgroundTask( () => {});
new Task ( () => {
DoWork();
UIApplication.SharedApplication.EndBackgroundTask(taskID);
}).Start();
}
The other approach is using remote notifications which means applications can register to receive notifications from a provider, and use the notification to kick off an update before the user opens the application.

Detect App idle time period for iOS in Xamarin forms

I recently started working in Xamarin forms and quite happy to be part of Xamarin community. I've a requirement to kick out the loggedIn User if he is idle on app for 10 mins. I got through of it in Android part using usual Life Cycle methods (combination of OnResume/OnPause) but not yet succeeded in iOS app.
I've hard time trying to find a solution over the internet but not able to find the one so far. I also tried with using Some Life cycle methods like WillEnterForeground/DidEnterbackground but due to some reason these method are not invoked on desired actions.
FYI, I am from the Android background so not expertise in iOS.
Any help would be highly appreciated or let me know If I am missing anything.
in App class
DateTime sleepTime;
protected override void OnSleep()
{
base.OnSleep();
sleepTime = DateTime.Now;
}
protected override void OnResume()
{
base.OnResume();
var sleepDuration = DateTime.Now - sleepTime;
}

iOS Corespotlight search: When app is not running

When the app is running, the continueUserActivity method gets called in which I handle the deep linking into the right location. However, when the app is not running, this function never gets called. I believe in the case when the app is not running, the call goes into application:didFinishLaunchingWithOptions:.
public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
if (userActivity.UserInfo.ContainsKey(CSSearchableItem.ActivityIdentifier))
{
// do stuff to handle deep link
}
}
The above implementation works fine when the app is backgrounded, but when I kill it the search results no longer deep link correctly.
Any clue on how to handle this in application:didFinishLaunchingWithOptions:? Is there a way to tell if the app is launched from a corespotlight search item specifically?
I just checked in my app by adding an alert to both methods.
When the app is running only the continuation method is called. When the app is not running both methods will be called.

Close a mobile web application running under Trigger.IO

What is the best practise for telling your application to close when hosting it with Trigger.IO?
I want a button on the front to exit the application... I heard that for Android navigator.app.exitApp(); works, but got an error saying exitApp() didnt exit, but am hoping there is a more cross browser solution.
You can use forge.event.backPressed to listen for back button presses, and optionally quit the app there. E.g.:
forge.event.backPressed.preventDefault(function () {
forge.event.backPressed.addListener(function (closeMe) {
closeMe(); // this closes the app
});
});
James posted the documented method of closing the app, but the internal method can also be called like this:
forge.internal.call('event.backPressed_closeApplication');
This method is confirmed to work on Android, unsure whether it will work on iOS.

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