What is wrong

volvomann

Active Member
Licensed User
Longtime User
Hallo i tried to read out this file into a label, there is 6 lins saved with writline
I got this error ( java.lang.nullpointer expection)


B4X:
sub smsbmi 

Dim textreader1 As TextReader


     textreader1.Initialize(File.OpenInput(File.DirRootExternal &"/pulsdata/mail", "Helge.doc"))
    Dim linje As String
    linje = textreader1.ReadLine    
    Do While linje <> Null
         linje = textreader1.ReadLine
       Lab.Text=linje
         Loop
    
    textreader1.Close

        
     
End Sub
 

volvomann

Active Member
Licensed User
Longtime User
Your loop is wrong.
It should be:
B4X:
 linje = textreader1.ReadLine    
Do While linje <> Null
         Lab.Text=linje
          linje = textreader1.ReadLine
Loop

Ok no error but only the last saved line is shoin upp in the label.
 
Upvote 0

JCO

Active Member
Licensed User
Longtime User
That's logical, since you are overwriting the value on every iteration.
Try changing to this:


B4X:
 linje = textreader1.ReadLine    
Do While linje <> Null
          linje = linje & crlf & textreader1.ReadLine
Loop
     Lab.Text=linje

Apparently our posts crossed...
 
Last edited:
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
Is i posible to get all 6 lines from lab.text to be sendt on sms

like i do whith one line xxxx.text (SendSms("xxxxxxxxx",Lab.text)

When i tried this i got the same error ( java.lang.nullpointer expection)
 
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
Yes. Run your program in debug mode to find the source of this error.

It is here it works whith one line in the lab.text. i use it somwhere else in this app and i another apps:
is there a limit for how mutch text i can putt in sthe string?
B4X:
r.RunMethod4("sendTextMessage", Array As Object(PhoneNumber, Null, Text, Null, Null),

B4X:
Sub SendSms(PhoneNumber As String, Text As String)
    Dim ps As PhoneSms
    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    r.RunMethod4("sendTextMessage", Array As Object(PhoneNumber, Null, Text, Null, Null), _
     Array As String("java.lang.String", "java.lang.String", "java.lang.String", _
     "android.app.PendingIntent", "android.app.PendingIntent"))
End Sub
 
Last edited:
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
View attachment log.txt

Here is the log I thing it is the lengt off the text that cause the problem when remove som lins in the file it is ok. How can I get the text to been sendt in to sms like i do on the phone And likly camtrue like one sms?
 
Last edited:
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
No Iàm sure that it is the 160 chr limit that cause the problem, but i cant figure out how to fix the problem:
 
Upvote 0
Top