Question

Background:

I am creating an application using Cordova that should run on both iOS and Android. I'm using SenchaTouch for the UI so that the codebase for the UI is the same for both iOS and android. I'm using barcode scanner plugin for Cordova for iOS and android. the scanner activity gets triggered by the JavaScript code. In my JS code after calling barcodeScanner's scan function I have set timeout for 15s after which I alert the user if there is no barcode is scanned.

This works fine in iOS.

Problem:

My problem is that Once the ScannerActivity starts the MainActivity (which in Cordova contains the webview which runs JS) goes to the background and is automatically stopped by android system. This means that my JS code no longer runs. I need/want to trigger, through JS, an alert, after pausing the ScannerActivity but not stopping the ScannerActivity. For this I need a way to keep the MainActivity running in the background.

Solutions:

I've been doing searches online all day and so far it appears that there is no way to accomplish this. But somehow I think there should be a way to do this.

Was it helpful?

Solution

You could create some sort of thread or service that can run in the background that you trigger every time it is needed. Or you integrate your ScannerActivity into the MainActivity.

Otherwise it is standard behavior that non-shown activities are being stopped/paused, except if it is a service/thread/activity without ui.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top