I'll admit that I don't know Android development as well as others, but maybe I can still help. Here are a few things that you can try which may help your out (then again they may not).
1) Using Final:
You say that you have this line somewhere
as long as selectedApps will only/always be using that single ArrayList then you can replace it with
. You will still be able to use all of the ArrayList methods like Add, Remove etc, you will just not be able to reinitialize the variable to point to something else.
This is a good thing. In doing this, if you get an error about trying to reinitialize the variable then you may have done something wrong.
At the same time, unless you are planning on subclassing or extending your Activity classes I think that you can make them final as well. You may be able to even make your Switch final
Some JVM languages ensure that you make everything final for classes and variable unless otherwise specified.
I believe that this is part of the "Effective Java" book/guidelines. You can read more about this if you Google for "effective
java final variables"
2) Adding the onClick:
To add the onClick and/or onLongClick to your Recyclerview you have to do a couple of small things as noted in the following tutorials:
https://antonioleiva.com/recyclerview-listener/
https://android.jlelse.eu/click-listener-for-recyclerview-adapter-2d17a6f6f6c9
https://newfivefour.com/android-item-click-listener-recyclerview.html
Yes, there are different ways to do this. I think that one of the best would be to implement the view.onclick and view.onlongclick interfaces in the viewholder class.
3) Use different variable names for
testing:
To make sure that names don't collide and that you are not overwriting any values.
I suggest that you do something like
selectedAppsAct1 instead of
selectedApps and
applicationsActivity.selectedAppsAct2 instead of
applicationsActivity.selectedApps.
With Android Studio this can take minutes to do using the Refactor commands.
4) Unit testing:
You have not mentioned too much or anything about Unit tests. You may want to add in some basic unit tests before too long so that you can be sure your code works when you need to update it.
There are many volumes on unit testing in general as well as for Android development.
5) Design
Patterns:
Are you using any design patterns? There is MVC, MVVM, MVP and others that can be used with Android development. Using these well established design patterns some things like unit testing and code refactoring can be done easier.
There are many volumes on design patterns in general as well as for Android development.
In handling the above points you may walk away with your application being programmed in a totally different way then your first expected.
Please note that these are only some suggestions and nothing "has to be done" with the suggestions.
Also, everyone on this site does have full time jobs and they are volunteering their time an knowledge to help people out.
Adam Wentz wrote:Although I have suspicions as to what is happening, it is only speculation because I cannot collect enough debug info.
What do you suspect is happening?
Follow up questions:
I guess that you are using the Android Emulator for your development.
If this is the case have you tried with a different emulated device running a different version of Android to see if the result is the same?Have you tried running this code on a actual physical device?
Was the result the same?
What is the "ideal" device, specification wise that you want your program to run on?
Memory?
Android Version?
Chipset (intel, arm etc)?