treehousefrog Member Licensed User Longtime User Jan 8, 2014 #1 Hey guys, I need a little help with the launchers I'm building... Basically I am loading a list of applications on the device into a listview with icons and am handling this in a timer. Unfortunately though, if I test this on a device that has lots of apps installed, it then causes the app to crash, presumably because it's out of memory... Here's the code I'm using: Code: Copy bloot = packman1.GetApplicationIcon(s.Split(placer, "@").Get(1)) allapps.AddTwoLinesAndBitmap(s.Split(placer, "@").get(0), s.Split(placer, "@").Get(1), bloot.Bitmap) Is there anything I could do to reduce the strain and prevent crashing? I know lots of other apps that load icons into a list, so there must be a way! Thanks so much in advance guys :-D This one has been bugging me for a while now!
Hey guys, I need a little help with the launchers I'm building... Basically I am loading a list of applications on the device into a listview with icons and am handling this in a timer. Unfortunately though, if I test this on a device that has lots of apps installed, it then causes the app to crash, presumably because it's out of memory... Here's the code I'm using: Code: Copy bloot = packman1.GetApplicationIcon(s.Split(placer, "@").Get(1)) allapps.AddTwoLinesAndBitmap(s.Split(placer, "@").get(0), s.Split(placer, "@").Get(1), bloot.Bitmap) Is there anything I could do to reduce the strain and prevent crashing? I know lots of other apps that load icons into a list, so there must be a way! Thanks so much in advance guys :-D This one has been bugging me for a while now!
Erel B4X founder Staff member Licensed User Longtime User Jan 8, 2014 #2 What is the error message? Upvote 0
LucaMs Expert Licensed User Longtime User Jan 8, 2014 #3 I tried in this way (without timer) and it does not create problem Code: Copy Sub LoadAppsListView Dim packages As List Dim AppPckgName As String Dim iconDrw As BitmapDrawable packages = pm.GetInstalledPackages ListView1.Clear For i = 0 To packages.Size - 1 AppPckgName = packages.Get(i) Log(AppPckgName) iconDrw = pm.GetApplicationIcon(AppPckgName) ListView1.AddTwoLinesAndBitmap2("booo " & i, "booooo " & i, iconDrw.Bitmap, AppPckgName) Next End Sub Indeed, it has some problems: I do not have the amount of apps that it lists (many of them probably are services) Last edited: Jan 8, 2014 Upvote 0
I tried in this way (without timer) and it does not create problem Code: Copy Sub LoadAppsListView Dim packages As List Dim AppPckgName As String Dim iconDrw As BitmapDrawable packages = pm.GetInstalledPackages ListView1.Clear For i = 0 To packages.Size - 1 AppPckgName = packages.Get(i) Log(AppPckgName) iconDrw = pm.GetApplicationIcon(AppPckgName) ListView1.AddTwoLinesAndBitmap2("booo " & i, "booooo " & i, iconDrw.Bitmap, AppPckgName) Next End Sub Indeed, it has some problems: I do not have the amount of apps that it lists (many of them probably are services)
mc73 Well-Known Member Licensed User Longtime User Jan 8, 2014 #4 What is you timer's interval? Perhaps this sub is entered again during still executed. If this is the case, you should disable the timer as long as you're still processing data or set a flag to exit this sub. Upvote 0
What is you timer's interval? Perhaps this sub is entered again during still executed. If this is the case, you should disable the timer as long as you're still processing data or set a flag to exit this sub.
treehousefrog Member Licensed User Longtime User Jan 8, 2014 #5 Hey guys, Thanks so much for the quick responses :-D The app simply force closes (no error message), and it tends to do it after loading around 300 icons (pretty consistently regardless of what apps are installed). I previously did it your way Lucas, but it caused the app to freeze for too long the first time it loaded and on orientation changes... I did think something like that mc73 - could you possibly show me how to go about implementing one of those solutions? How do I find out if the app is still processing data? Thanks again everyone! Upvote 0
Hey guys, Thanks so much for the quick responses :-D The app simply force closes (no error message), and it tends to do it after loading around 300 icons (pretty consistently regardless of what apps are installed). I previously did it your way Lucas, but it caused the app to freeze for too long the first time it loaded and on orientation changes... I did think something like that mc73 - could you possibly show me how to go about implementing one of those solutions? How do I find out if the app is still processing data? Thanks again everyone!
stevel05 Expert Licensed User Longtime User Jan 8, 2014 #6 Have you checked the unfiltered log? Upvote 0
LucaMs Expert Licensed User Longtime User Jan 8, 2014 #7 My test lists 126 items. I've added a listiview.invalidate + DoEvents; in spite of this, it takes one or two seconds (my smartphone is not fast). Of course, changing the orientation, I lose everything! Upvote 0
My test lists 126 items. I've added a listiview.invalidate + DoEvents; in spite of this, it takes one or two seconds (my smartphone is not fast). Of course, changing the orientation, I lose everything!