it could also be that when you save the variable it was already a NULL value. (but i dont think this is your problem)
what seems more logical for me is you are trying to read 8 lines to 8 variables but have only 7 lines (or less)
the reason for that could be that a variable was "" and if you try to writeline "" it wont write anythig to your text file and just skip to the next line
for example, i have 8 strings (or any other type that doesnot matter) and the string looks like this:
Dim str1 = "1", str2 = "2",str3 = "3",str4 = "4",str5 = "",str6 = "6",str7 = "",str8 = "8" As String
you can see the str5 and str7 are "" (so an empty string)
now when we would save all 8 strings to a textfile we would expect to read again 8 variables right??
well we wont get 8 variables the reason is, when we try to save str5 and str7 the writline process will skip those strings since they are empty
and we will get only 6 variables.
Sub Activity_Create(FirstTime As Boolean)
'create text file
Dim str1 = "1", str2 = "2",str3 = "3",str4 = "4",str5 = "",str6 = "6",str7 = "",str8 = "8" As String
Dim textwriter As TextWriter
textwriter.Initialize(File.OpenOutput(File.DirInternal,"1.txt",False))
textwriter.WriteLine(str1)
textwriter.WriteLine(str2)
textwriter.WriteLine(str3)
textwriter.WriteLine(str4)
textwriter.WriteLine(str5)
textwriter.WriteLine(str6)
textwriter.WriteLine(str7)
textwriter.WriteLine(str8)
textwriter.Close
'read text from file
Dim all_lines As String
Dim tr As TextReader
tr.Initialize(File.OpenInput(File.DirInternal,"1.txt"))
all_lines = tr.ReadAll
log_all_lines(all_lines)
End Sub
Sub log_all_lines(all_lines As String)
Dim arr() As String = Regex.Split(CRLF,all_lines)
For i = 0 To arr.Length -1
Log(arr(i))
Next
End Sub
this is the log i get:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
1
2
3
4
6
8
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
you can see i have only 6 lines and not 8 so what i am trying to say when you save your variables you must check that they are not blank ("") if the are
then change them to " " (put a space inside) otherwise you will have missing lines
what i believe is that in some devices they could not get all variables and instead they get a blank variable that was not written to the text file and thatshwy they had
a null exception.
so you need to make sure your variables are not blank, like:
if BT_MacAdr = "" then BT_MacAdr = " "