Problem when I reopen

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
On the device, I open my app and everything is fine. If I use the back button on my smartphone (galaxy S2) the application closes, but when I reopen I have the error message joined. Yet my imgview is initialized, I use the designer for panels and IMgViews.
thank you
 

Attachments

  • error.png
    61.6 KB · Views: 328

ciginfo

Well-Known Member
Licensed User
Longtime User
Here my Activity_Create

HTML:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
   'xxxxx Splash Screen   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
   
   Timer1.Initialize("Timer1", 8000)
   Timer1.Enabled=True
   Img_Splash.Initialize("")
   Panel_Splash.Visible=True
   

   'XXXXXXX  TABHOST XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

   Dim bmp1_viandes, bmp2_viandes, bmp1_volailles, bmp2_volailles, bmp1_poissons, bmp2_poissons, bmp1_patisseries, bmp2_patisseries As Bitmap
   Dim bmp1_menu, bmp2_menu As BitmapDrawable
   bmp1_viandes = LoadBitmap(File.DirAssets, "viandes_01.png")
   bmp2_viandes = LoadBitmap(File.DirAssets, "viandes_02.png")
   bmp1_volailles  = LoadBitmap(File.DirAssets, "volailles_01.png")
   bmp2_volailles  = LoadBitmap(File.DirAssets, "volailles_02.png")
   bmp1_poissons  = LoadBitmap(File.DirAssets, "poissons_01.png")
   bmp2_poissons  = LoadBitmap(File.DirAssets, "poissons_02.png")
   bmp1_patisseries  = LoadBitmap(File.DirAssets, "patisseries_01.png")
   bmp2_patisseries  = LoadBitmap(File.DirAssets, "patisseries_02.png")
   
   'TabHost1.AddTabWithIcon ("Volailles",  bmp1_viandes, bmp2_viandes, "volailles")
   TabHost1.AddTabWithIcon ("Viandes", bmp1_viandes, bmp2_viandes, "viande")
   TabHost1.AddTabWithIcon ("Volailles", bmp1_volailles, bmp2_volailles, "volailles")
   TabHost1.AddTabWithIcon ("Poissons", bmp1_poissons, bmp2_poissons, "poissons")
   TabHost1.AddTabWithIcon ("Patisseries", bmp1_patisseries, bmp2_patisseries, "patisseries")
   'TabHost1.AddTab("Accueil", "Accueil") 'Titre dans l'onglet, nom de la page à charger

'Installe la liste des viandes
   'Arrondit certains labels
   gd1.Initialize("TOP_BOTTOM",cols1)
     gd1.CornerRadius = 20
   LblNomViande.Background = gd1
   LblNomViande.Color = Colors.ARGB (255,139,0,0)'rouge foncé
   'Charge une image   
   BmpViande = LoadBitmap(File.DirAssets, "viandes_01.png")
   ImgViewViande.Gravity = Gravity.FILL
   ImgViewViande.Bitmap = BmpViande
   
   'ListView proprement dit 
   ListViewViandes.SingleLineLayout.Label.TextSize = 14 'Taille des labels
   ListViewViandes.SingleLineLayout.ItemHeight = 25dip 'auteur de l'item
   ListViewViandes.Color = Colors.Gray 'Couleur fond du listview
   ListViewViandes.SingleLineLayout.Label.Color = Colors.ARGB (255,139,0,0) 'couleur du fond de l'item
   ListViewViandes.SingleLineLayout.Label.TextColor = Colors.White 'Couleur du texte
   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   ListViewViandes.AddSingleLine("Agneau (Gigot)")'220°, 25, P
   ListViewViandes.AddSingleLine("Agneau (Selle)")'220°, 32, P
   ListViewViandes.AddSingleLine("Autruche (Roti)")'210°, 10, P
   ListViewViandes.AddSingleLine("Boeuf (Côtes)") '225°, 15' P
   ListViewViandes.AddSingleLine("Boeuf (Roti saignant)")'200, 15, P
   ListViewViandes.AddSingleLine("Boeuf (Rosbif à point)")'200, 20' P
   ListViewViandes.AddSingleLine("Boeuf (Rosbif bien cuit)")'200, 25' P
   ListViewViandes.AddSingleLine("Kangourou (Roti)") '210°, 20' P
   ListViewViandes.AddSingleLine("Lapin") 'Lapin entier, 35 mn au four à 240°C.
   ListViewViandes.AddSingleLine("Porc (Côtes de)")'225° 12' P
   ListViewViandes.AddSingleLine("Porc (Roti)") '180° 45' P
   ListViewViandes.AddSingleLine("Porc (Rouelle)") '190° 120' 
    ListViewViandes.AddSingleLine("Veau (Roti de)") '180°, 50' P
   
   
   
'Installe la liste des volailles
   BmpVolaille = LoadBitmap(File.DirAssets, "volailles_01.png")
   ImgViewVolaille.Gravity = Gravity.FILL
   ImgViewVolaille.Bitmap = BmpVolaille
   
   ListViewVolailles.SingleLineLayout.Label.TextSize = 14 'Taille des labels
   ListViewVolailles.SingleLineLayout.ItemHeight = 25dip 'auteur de l'item
   ListViewVolailles.Color = Colors.Gray 'Couleur fond du listview
   ListViewVolailles.SingleLineLayout.Label.Color = Colors.ARGB (255,184,134,11) 'couleur du fond de l'item
   ListViewVolailles.SingleLineLayout.Label.TextColor = Colors.White 'Couleur du texte
   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   
   ListViewVolailles.AddSingleLine("Autruche (Roti)")'210°, 10, P
   ListViewVolailles.AddSingleLine("Caille")'180°, 30'
   ListViewVolailles.AddSingleLine("Caille braisée")'180° 45
   ListViewVolailles.AddSingleLine("Canard rosé")'240 à 250, 15' Four ou broche P   
    ListViewVolailles.AddSingleLine("Canard à point")'240 à 250, 30' Four ou broche P
   ListViewVolailles.AddSingleLine("Canard magret rosé")'220 , 20   
   ListViewVolailles.AddSingleLine("Canard magret à point")'225 , 20
   ListViewVolailles.AddSingleLine("Chapon")'170 à 180, 30' Four puis 200 à 220 les 15 der mn P
   ListViewVolailles.AddSingleLine("Dinde")'240 à 250, 25' Four ou broche P
   ListViewVolailles.AddSingleLine("Oie")'200 à 220 , 30' P
   ListViewVolailles.AddSingleLine("Poulet")'240 à 250, 25' Four ou broche P
    ListViewVolailles.AddSingleLine("Pintade")'240 à 250, 30' Four ou broche P
   

'Installe la liste des Poissons
   BmpPoisson = LoadBitmap(File.DirAssets, "poissons_01.png")
   ImgViewPoisson.Gravity = Gravity.FILL
   ImgViewPoisson.Bitmap = BmpPoisson
   
   ListViewPoissons.SingleLineLayout.Label.TextSize = 14 'Taille des labels
   ListViewPoissons.SingleLineLayout.ItemHeight = 25dip 'auteur de l'item
   ListViewPoissons.Color = Colors.Gray 'Couleur fond du listview
   ListViewPoissons.SingleLineLayout.Label.Color = Colors.ARGB (255,0,100,0) 'couleur du fond de l'item
   ListViewPoissons.SingleLineLayout.Label.TextColor = Colors.White 'Couleur du texte
   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   ListViewPoissons.AddSingleLine("Bar")'30 mn environ à four chaud
   ListViewPoissons.AddSingleLine("Barbue")'Entier ou en filets, 20' au four chaud
   ListViewPoissons.AddSingleLine("Cabillaud")'
   ListViewPoissons.AddSingleLine("Carrelet")'8 à 10 Min grillé au four
   ListViewPoissons.AddSingleLine("Colin")'10 mn à four trés chaud puis 10 mn à four doux
   ListViewPoissons.AddSingleLine("Dorade")'Entière, 30 mn à four chaud
   ListViewPoissons.AddSingleLine("Grondin")'15 à 20 mn à four chaud
   ListViewPoissons.AddSingleLine("Hareng")'15 mn en papillotte à four chaud
   ListViewPoissons.AddSingleLine("Lotte")'25 Min braisée au four
   ListViewPoissons.AddSingleLine("Maquereau")'15 à 20 mn à four chaud selon la taille
   ListViewPoissons.AddSingleLine("Merlans")'10 à 15 mn à four chaud
   ListViewPoissons.AddSingleLine("Sardine")'4 à 6 min coté grill
   ListViewPoissons.AddSingleLine("Saumon Papillottes")'210°, 20'
   ListViewPoissons.AddSingleLine("Saumon Pavés")'200°, 12'
    ListViewPoissons.AddSingleLine("Sole")'20 à 25 mn à four chaud
   ListViewPoissons.AddSingleLine("Thon")'20 mn à four chaud
   ListViewPoissons.AddSingleLine("Turbot")'20 à 30 mn au four chaud   
    

'Installe la liste des Patisseries
   BmpPatisserie = LoadBitmap(File.DirAssets, "Patisseries_01.png")
   ImgViewPatisserie.Gravity = Gravity.FILL
   ImgViewPatisserie.Bitmap = BmpPatisserie
   
   ListViewPatisseries.SingleLineLayout.Label.TextSize = 14 'Taille des labels
   ListViewPatisseries.SingleLineLayout.ItemHeight = 25dip 'auteur de l'item
   ListViewPatisseries.Color = Colors.Gray 'Couleur fond du listview
   ListViewPatisseries.SingleLineLayout.Label.Color = Colors.ARGB (255,255,20,147) 'couleur du fond de l'item
   ListViewPatisseries.SingleLineLayout.Label.TextColor = Colors.White 'Couleur du texte
   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   ListViewPatisseries.AddSingleLine("Choucroute")'175, 120'
   ListViewPatisseries.AddSingleLine("Gratin Dauphinois")'175°, 30'
    ListViewPatisseries.AddSingleLine("Pizza")' 6 à 7 mn au four à 210°.
   ListViewPatisseries.AddSingleLine("Quiche Lorraine")'Enfourner à four chaud (180°C) pendant 25 à 30 minutes
   ListViewPatisseries.AddSingleLine("Soufflé au fromage")'20 mn environ à 200°.   
    ListViewPatisseries.AddSingleLine("Tarte aux pommes")'30 mn au four à 200°.
   ListViewPatisseries.AddSingleLine("Tarte Tatin")' 20 mn à 180
    'ListViewPatisseries.AddSingleLine("Gratin Dauphinois")'1h à 200°C (th 7) puis 20 mn à 180°C (th6)
   
   
'xxxxxxxxxxxxxx PUB  xxxxxxxxxxxxxxxxxxxxxxxxxx
   HttpUtils.CallbackActivity = "Main"
   HttpUtils.CallbackJobDoneSub = "JobDone"
   HttpUtils.CallbackUrlDoneSub = "UrlDone"
   HttpUtils.PostString("POST Job1", PostUrl, "key1=value1&key2=value2")
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I tried your program and get also the errror.
I don't really understand why this happens.
I tried different things and found that removing the Img_Splash ImageView removes the error.
I don't understand why you have a Panel and an ImageView to show the splash screen. Couldn't you use the Panel with Bitmap Drawable and set the splash image to it.
Unfortunately I can't test the program further because the image files for the TabHost are missing.

Best regards.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User

I can't reproduce the issue on my device with Android 2.3.6.

In your code, I notice that you initialize two times your Img_Splash (once in the designer and once in Activity_Create) and that you start a timer in Activity_Pause. Why ?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I tried quite some different possibilities on my Nexus One and it seems that it's a memory problem.
When I run the program you posted as it is I get the 'Object should first be initilized' error directly at the first run !
Then I changed the background image of Img_Splash from accueil2 to oeuf and it works.
Perhaps you should have a look HERE.

By the way, pretty nice application !

Best regards.
 
Last edited:
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
A have removed Img_Splash and kept only Panel_Splash vith accueil2 into bitmapdrawable. Now it works nice.
Thank you.
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
A have removed Img_Splash and kept only Panel_Splash vith accueil2 into bitmapdrawable. Now it works nice.
Thank you.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…