Android Question getdata from intent null error

Milan Bozic

Member
Licensed User
In getting data from an intent, I get error

Error occurred on line: 1124 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference


B4X:
Sub GetIntentData(i As Intent) As String
    Dim r As Reflector
    r.Target = i
    Return r.RunMethod("getDataString")
End Sub

B4X:
If Activity.GetStartingIntent <> intent1 Then
        Dim dstest As Boolean
        Dim DataString As String
        intent1 = Activity.GetStartingIntent
        'only after initialization complete
        If (intent1 <> Null) And (AllDone = True) Then
            Log ("ok intent")
           
            'Log(GetIntentData(intent1))  ''this one works
            Log (intent1.GetData) ''this one does not work!! line 1124
            'see https://www.b4x.com/android/forum/threads/using-intent-getdata.11055/
            'but was an old one .. how come???
       
        dstest = intent1.HasExtra("com.symbol.datawedge.data_string")


Found solution in this link:
https://www.b4x.com/android/forum/threads/using-intent-getdata.11055/

Strange thing: when using b4a version 8.30 there was no error, then upgraded to b4a 8.80, and error popped up.
 
Top