Hi,
I am working on an Android Alloy app that has two very weird issues and I was hoping that someone could give me a hand.
The app is using the com.tripvi.drawerlayout and that might be related although I am not sure how.
Problem 1:
Occasionally after starting the app clicking on a link to open another window with a call to Alloy.createController('newWindow') I get an error that Alloy has not been defined. The error appears to be because of me defining fonts and other screen parameters in newWindow.tss using Alloy.Globals.ThemeXXXX variables.
Killing and restarting the app makes everything work as expected. I have not figured out how to reliably reproduce this problem. It happens from time to time and only if the app has previously been exited from (exitOnClose=true in the main window for the app) and the app has not been removed from the Android's recent apps list.
The interesting thing is that the main screen shows up just fine with all of its content and there are plenty of styles that use Alloy.Globals.... references in it. Why would Alloy become undefined all of a sudden?
I have tried to override the android:back event and not allow the users to ever exit the app and that helps avoid the problem but it does not feel right.
Problem 2:
The main screen of the app has a ScrollView, which is populated at initial launch with some data. (Code very much like the example on how to use ScrollView instead of TableView). User activity refreshes the ScrollView from time to time and everything is working EXCEPT .... when the app is restarted (like with problem 1) it can no longer update the ScrollView unless the app is cleared from Android's recent apps list and started again.
To refresh the view in the controller for the main screen I use an event handler for my own event inside of which calls to $.scrollViewName.removeAllChildren() and $.scrollViewName.add() do the update of the scroll view.
I changed the code a bit to store $.scrollViewName into a global variable
Alloy.Globals.myScrollView = $.scrollViewName
and updated the refresh code to use the gloval variable instead.
That made things work regardless of how the app was started. I am not sure I understand why and it feels like it might offer a clue to what is behind Problem 1, which is why I have described it.
What is so special about removing the app from the Android's recent apps list? It would appear that when the user used the back button to exit the app it did not completely clean up something. and removing the app from the recent apps list cleans it up. Is there any way to address this?
It feels like something similar to finish() on current activity before exit would help but It is not a call to Ti.Android.currentActivity.finish() - I have tried that and did not change a thing.
Is it possible that the drawerlayout plugin is somehow responsible for this?
I have not provided any code examples because I am not really sure what to include. Problem 1 cannot be reproduced consistently - perhaps once every 10-15 times I start the app but never after fresh install.
Any suggestions as to what to look for?
Thank you much!