Android Question (java line:357)java.lang.nullpointerexception

riano_defretes

Member
Licensed User
hi erel,

when i try to load sms, error appear like (java line:357)java.lang.nullpointerexception,

this is my code, can you help me? thx

Sub ceksms
Dim Smsmessage1 As SmsMessages
Dim liste As List
Dim Sms As Sms
Dim x As String
liste.Initialize
liste = Smsmessage1.GetAll
For i = 0 To liste.Size -1
Dim Sms As Sms
Sms = liste.Get(i)
If Sms.Address = "12345" Then
x = Sms.Address
listview1.AddSingleLine2(x, Sms.Body)
End If
Next
End Sub
 

riano_defretes

Member
Licensed User
hi erel,

something's wrong because i do not limit my questions to a single member.

in debug mode, everything is ok in emulator, but in the real phone that error apear
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Hard to say without seeing more logs. But have you called listview1.initialize before using it in your Sub?
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Even if you are in your real device, if you load the app through USB (doesn't matter if it is in debug or release mode), you will be able to see the logs
 
Upvote 0

riano_defretes

Member
Licensed User
@JordiCP : this is an error when using usb

Error occurred on line: 41 (Main)
java.lang.NullPointerException
at b4a.example.main._ceksms(main.java:405)
at b4a.example.main._activity_create(main.java:357)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:697)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5095)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
I tested your Sub and it worked for me.o_O

I suppose you are calling cecksms after your Activity.LoadLayout(..), right?

If so, the only thing coming to my mind is to move the call to "cecksms" from Activity_Create to Activity_Resume
 
Upvote 0
Top