Application restarting after going to home screen - codenameone

I have an android app designed using codename one
1)I run my application
2)I click on the home button of the phone.My app is taken away from my app and home screen is shown to me.
3)I again click on my application after navigating to it from the menu.
I expect that the state of my application be restored. But what happens is, my application restarts.
Also, this behaviour is arbitrary. Sometimes the application restarts and at other times the application resumes its state. Most of the times it restarts.
How do i ensure that my application always resumes its old state?

Android restarts running applications on some conditions to preserve RAM, battery etc. If you use the task switcher the application will resume properly but relaunching it often restarts it.
We are working on improving this behavior in the next update to Codename One, but you can use the stop method to store the application state into storage and use the start method to restore the application state.

Related

How to stop service worker creating cache?

I made a react web app. I added a service worker to get the PWA app. I just need the PWA app to add it on the home screen and use it on fullscreen view, I don't need any more functionalities like - offline browse, save cache, etc.
Now I am facing a problem, every time I deploy my app, I need to clear the browser cache. Sometimes I have to go to Incognito mode to see the changes.
So, How I will stop this?

stop() method will be called when App crashes in CN1

I would like to close the threads or clear cache if the App crashes or Phone switch off or some other abrupt actions. Please advise if this method only gets called when the user kill the App or Signout from the App.
I'm pretty sure stop() gets called when you force kill the app, switch apps, lock the screen, phone auto locks, or anything really where the app is no longer visible.
You can also check edge cases by connecting your Android (in dev mode) to your laptop, downloading platform-tools (logcat), adding a print statement inside the stop() function and using the following command "./adb logcat -s "System.out" inside the platform-tools directory. Not sure how to do it on iOS.

IntelliJ automatic updating of jsp files in GAE module stops working with server parameters --address=0.0.0.0

I have a GAE module on IntelliJ and when I after I edit the jsp files in it I can just go to the web browser, hit refresh and the changes show up. The other day I needed to access this from a different computer so I added --address=0.0.0.0 to the server parameters and after that changes to the jsp stopped showing up on the browser until I did a server restart. I removed the option and it started working again. Added it again and it stopped working, repeated several times, always the same result.
So how I can access the server from another computer yet have the ability to make changes and have those changes show up on the web browser without a server restart?
I am using an exploded war, and I have "update classes and resources" on both "on update" and "on frame deactivation".
This is with IntelliJ 13 on OSX 10.9
Thanks.
There are two ways to make iDEA update the runtime project:
Automatic via on frame deactivation, which means that IDEA updates project when you switch to another app (usually browser), i.e. when IDEA looses window focus. This works "automagically" while you test on the same computer, because you usually switch between IDEA and browser (or mobile emulator).
Manually via on update, which requires you to manually click the update button (the green circular arrows) in IDEA inside the running project pane.

How to integrate payment gateway in applications created using javascript frameworks like ExtJs?

Our application is a one-page application created using ExtJs. For any user action, the browser tab is never reloaded and all the actions are performed using ajax. A user can open/close multiple ExtJs windows/panels within the same browser tab, and this way everything remains confined to the same browser tab.
Now, we need to integrate payment gateway in the application, which involves redirecting the user to the bank website and having her brought back to our application.
The issue is that when browser redirects the user, then all the application javascript code along with panels and windows get destroyed, and when the user comes back to the application then she finds it to be different from one she left.
As a solution to this, we were thinking of using following two appraoches:
Option 1. Maintaining the state of application - When user leaves for the bank's website then somehow we maintain the state of application - like which windows are opened carrying what data, which variables have which values etc.. and when user returns back, we generate the same application state for her.
Option 2. Have a browser pop-up window for payment gateway - We intend to provide a button which will open a small pop-up window carrying the transaction details, and in this pop-up window the entire payment gateway process will take place taking care of redirection and everything.
Option 1 is proving to be very cumbersome and complicated as maintaining the exact state is not getting feasible.
For Option 2, we are not sure if this is safe and possible?
Has anyone implemented such an approach earlier. Otherwise, what are the other options which we can go for?
Thanks for any help in advance.
I faced the problem and I implemented it using websocket/polling in the main application while a new window pops up for the payment.
After the payment is successful the main application will be notified.
That way each payment runs in it own sandbox totally unbound from the main application which makes maintenance quite easy. Note that our backend create a new session for each payment using the existing one.
I think it is not uncommon to open new windows for payment that's why I decided to go this.

Populating data in Silverlight App before its sent to he browser

I have a Silverlight App which gets its data from a database. My Silverlight app (running in the browser) retrieves the data through a web service. Pretty standard setup.
But there is some data which has to be there all the time or the App is in an invalid state - think data to fill drop downs etc. So I need this data to be "pre-loaded" into the App before it's sent down to the client so that it's never in an invalid state. Today I load this data via a web service call when my first page is initialized which can some times take a few seconds - during that time my App is in an invalid state.
Is there a way to populate data (from a backend database) in my Silverlight App before it's sent to the browser?
It is valid for an app to start and not be ready to use for a while, so long as the user cannot interact with it (or see the broken bits:))
Better to ensure your app has a splash screen/login page etc that displays until such time as the required resources are loaded. Once loaded you can set an app state to then show the main screen.
I had the same problem with a website that loaded the menu items via a service (as the text was data driven). Wound up running a progress spinner over the top (with a full-screen background).
I don't think you can. The application runtime occurs on the client's machine. I would suggest putting up a loading dialog while you bring those items down from the database.
What HiTech Magic said. Best practice for this is to use a splash screen or login page. You can also have your buttons (and interaction) disabled by default, and after the data is loaded, enable the UI. I would go with the spash screen though..

Resources