App works on Nexus but not on cell

CD Tom

Member
Licensed User
Longtime User
My app works great on my nexus 7 but when I load it on my cell phone and run it I get an error "An error has occurred in sub:main_sv_itemclick(java line: 775) Object should first be initialized(map)" Heres the code for the sv_itemClick
B4X:
Sub sv_ItemClick(Value As String)
   Dim id As String
   Dim m As Map
   Dim Val() As String
   id = 0
   LblFName.Visible = True
   lblDJoined.Visible = True
   lblbdate.Visible = True
   lblassoc.Visible = True
   lblpaid.Visible = True
   imgview.Visible = True
   lblsign.Visible = True
   btnAssoc.Visible = True
   Val = Regex.Split(",", Value)
   m = DBUtils.ExecuteMap(SQL1, "SELECT mbr_first_name, mbr_last_name, address_1, city, state, zip_code, e_mail, home_phone, datej, description, birthd, duesp, assc_last_name, assc_first_name, mbr_prox, assoc_prox, reldate FROM mbrs where mbr_number = ?", Array As String(Val(2)))
   If m = Null Then 
      lblFLName.Text = "N/A"
   Else
      id = m.Get("mbr_prox") ' load mbr prox into i
      If File.Exists(File.DirRootExternal,"TCGCPhotos/"&id&".jpg") = True Then   
         picture = LoadBitmap(File.DirRootExternal,"TCGCPhotos/"&id&".jpg") 'this will load picture 
         imgview.SetBackgroundImage(picture) 'this will set picture
      Else
         picture = LoadBitmap(File.DirRootExternal,"TCGCPhotos/Noimages.jpg")
         imgview.SetBackgroundImage(picture)
      End If
      lblFLName.Text = m.Get("mbr_first_name") & "   " & m.Get("mbr_last_name")
      lblAddress.Text = m.Get("address_1")
      lblCSZ.Text = m.Get("city") & ", " & m.Get("state") & " " & m.Get("zip_code")
      lblPhone.Text = m.Get("home_phone")
      lblStatus.Text = m.Get("description")
      lblEmail.Text = m.Get("e_mail")
      lblJoined.Text = m.Get("datej")
      lblBirth.text = m.Get("birthd")
      lblduespaid.Text = m.Get("duesp")
      btnAssoc.Text = m.Get("assc_first_name") & "  " & m.Get("assc_last_name")
      lblrel.Text = m.Get("reldate")
   End If
   
End Sub
I don't get any errors when compiling.
also everything has scaled correctly except for the searchview which is code in a different module and I'm not sure how to scale that.

Thanks again for all your help.
If you need more information let me know.
 

CD Tom

Member
Licensed User
Longtime User
I made that change and still get the same error. I also put in a m.initialize and tried it again and got the same error. I don't have any other map in that routine so what's the error talking about.
Any ideas about the scaling of the searchview?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Run the code in Debug mode. You will see the line that raises this error.

Any ideas about the scaling of the searchview?
You can use Klaus AutoScale module to scale views at runtime. Another option is to add a "dummy" view with the designer. This view can be hidden. And set the SearchView size based on this view.
 
Upvote 0

CD Tom

Member
Licensed User
Longtime User
I'm still working on the problem with the cell phone I've tried running it on the cell in debug mode and the program stay it's stopped unexpectedly, I trying a couple more things and will let you know.
Being a real newbe to this I'm confused on how to use the scale module, I've download it and have tried to understand what I'm supposed to do. What part of the module to I put in my code and how do I get it to scale the SearchView module.
Forgive me for being such a pest.
 
Upvote 0

CD Tom

Member
Licensed User
Longtime User
Nothing seems to work on the cell, no matter where I put the pause in the sv_itemclick when the program stops and I hit the F8 key I get the program stopped unexpectedly and my only option is to force close. I don't know what to do.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
If Klaus or mc73 were reading this, the would suggest exporting your project as zip for forum users to check it out. That might be your best bet. Export it the way it has been running without error on the Nexus, with the necessary files (fake data in case you data is proprietary). Also, you need to indicate where the files reside. Also, state what phone you use and what operating system. I am sure someone has your phone.
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Seen this thread yesterday, but forgot to post my comment :)
How are you setting up your database to every new installation?
 
Upvote 0

CD Tom

Member
Licensed User
Longtime User
To answer MC73 yes if the database doesn't exist the the system recreates it. the then creates the table.
My cell phone is a Motorola running Android 2.2.3 The way the program acts on the phone is it loads the database with the data and allows me to search for the name of the member. When I tap on the users name I should get all information regarding the member displayed on the screen. That's what happens on the nexus 7. However on the cell phone when run not in debug mode it gives me the error "An error has occurred in sub:main_sv_itemclick(java line: 775) Object should first be initialized(map)" see the sv_itemclick earlier in this post. When I run the code in debug mode and put a pause in the sv_itemclick the program stops at the pause and when I press the F8 the program stops unexpectedly and it doesn't matter which line of code I put the pause on as long as it's before the id = m.get("mbr_prox") statement, That seems to be the line where the program stops with the unexpected error.
I'm going to need to come up with some test data before I zip this up.
 
Upvote 0

CD Tom

Member
Licensed User
Longtime User
In regards to the scale problem, I found where I set the Searchview
B4X:
   sv.AddToParent(Activity, 280, 100, 400dip, 300dip)
I'm sure this is what's causing the scale problem when running on the cell but not sure how to make it scale automatically. Just another one of my not knowing enough about this language.

Thanks
 
Upvote 0
Top