Android Question Sometimes my app does not work...

select

Member
Licensed User
Longtime User
I've made a simple app that list file from ftp.
I've initialized ftp in Process_Global then I've a button:
B4X:
FTP.List("/")
and in FTP_ListCompleted I fill a ListView and then it starts a new activity.

When key "back" is pressed it call Activity.Finish.

Everything works. I start my app, I press the button and the list is filled, I close the app (with back key) I restart it and it works again.

The problem came if I start my app, I fill the list, I close the app, I wait about two minutes or more (the screen of the phone turns off) I start my app again but when I press the button but the list is not filled, is empty.

The only way to resolve the problem is press the square button (android 5.02) and swipe the app (manually close I think). After this if I try to open and press the button the list is filled.

Can someone please help me with this problem?

tnx
 

Roycefer

Well-Known Member
Licensed User
Longtime User
ListViews are activity global objects. They will be created anew every time their owning Activity is created. I think instead of directly filling the ListView in FTP_ListCompleted you should fill a List that is declared in Process_Global. In Activity_Resume, then you can fill your ListView from that List if that List isn't empty. (Make sure to empty that List in your button press event).
 
Upvote 0

select

Member
Licensed User
Longtime User
Ok, but can I simulate with code (when back button is pressed) what I do to resolve the problem, press square button and swipe the app?

I used Activity.Finish in all my activity but it does not work...it would be easier...
 
Upvote 0
Top