T TomKluz Active Member Licensed User Longtime User Mar 4, 2019 #1 Hello, Hello, I am trying to start Bluetooth Chat example which I took from this community, published by Mr Erel. I only want to convert to AsyncStreamText class as I did in B4J. Unfortunatelly it didn't want work I am trying to use this form: AStream.Initialize(Me, "AStream", serial1.InputStream, serial1.OutputStream) but I am getting in a log panel a lot of red colour. I am attaching a screen shot about this. May I ask for help in this case ? TomKluz Attachments Log_B_Chat.jpg 90.9 KB · Views: 587
Hello, Hello, I am trying to start Bluetooth Chat example which I took from this community, published by Mr Erel. I only want to convert to AsyncStreamText class as I did in B4J. Unfortunatelly it didn't want work I am trying to use this form: AStream.Initialize(Me, "AStream", serial1.InputStream, serial1.OutputStream) but I am getting in a log panel a lot of red colour. I am attaching a screen shot about this. May I ask for help in this case ? TomKluz
Erel B4X founder Staff member Licensed User Longtime User Mar 5, 2019 #2 1. Please right click on the logs and post the error as text. 2. Start with running the example as-is. It should work. 3. Explain the changes you made. Upvote 0
1. Please right click on the logs and post the error as text. 2. Start with running the example as-is. It should work. 3. Explain the changes you made.
T TomKluz Active Member Licensed User Longtime User Mar 5, 2019 #3 Dear Mr Erel I have started an axample as it is and it's working till the moment that after bluetooth connection a lot of foults appears in log panel. I didn't treated it as suspicious because on the other site is Arduino device sending data in text mode. I have been exerciseing this case with B4J (with your help) using AsyncStreamText class and finally it works well using 1 Arduino device. In case of B4A example the only change I have done is including a module of AsyncStreamText class, declaration of variable AStream as AsyncStreamText, initialisation of AStream similary as I done in B4J and nothing else. Intention is to see data in text format and send simple commands back to Arduino within your chat example. After starting, an app is going to the same point as oryginal one. Complete log panel is below. Hoping this info is better than previous one and thank you in advance for your suport Should I send you complete code ? TomKluz You can see all from log panel Logger connected to: HTC HTC One A9s --------- beginning of main --------- beginning of system ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** connected: true ** Activity (main) Pause, UserClosed = false ** ** Activity (chatactivity) Create, isFirst = true ** Error occurred on line: 23 (ChatActivity) java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream android.bluetooth.BluetoothSocket.getInputStream()' on a null object reference at anywheresoftware.b4a.objects.Serial.getInputStream(Serial.java:256) at anywheresoftware.b4a.samples.bluetooth.chatactivity._activity_create(chatactivity.java:361) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144) at anywheresoftware.b4a.samples.bluetooth.chatactivity.afterFirstLayout(chatactivity.java:104) at anywheresoftware.b4a.samples.bluetooth.chatactivity.access$000(chatactivity.java:17) at anywheresoftware.b4a.samples.bluetooth.chatactivity$WaitForLayout.run(chatactivity.java:82) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:227) at android.app.ActivityThread.main(ActivityThread.java:6100) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:961) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:822) ** Activity (chatactivity) Resume ** . Upvote 0
Dear Mr Erel I have started an axample as it is and it's working till the moment that after bluetooth connection a lot of foults appears in log panel. I didn't treated it as suspicious because on the other site is Arduino device sending data in text mode. I have been exerciseing this case with B4J (with your help) using AsyncStreamText class and finally it works well using 1 Arduino device. In case of B4A example the only change I have done is including a module of AsyncStreamText class, declaration of variable AStream as AsyncStreamText, initialisation of AStream similary as I done in B4J and nothing else. Intention is to see data in text format and send simple commands back to Arduino within your chat example. After starting, an app is going to the same point as oryginal one. Complete log panel is below. Hoping this info is better than previous one and thank you in advance for your suport Should I send you complete code ? TomKluz You can see all from log panel Logger connected to: HTC HTC One A9s --------- beginning of main --------- beginning of system ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** connected: true ** Activity (main) Pause, UserClosed = false ** ** Activity (chatactivity) Create, isFirst = true ** Error occurred on line: 23 (ChatActivity) java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream android.bluetooth.BluetoothSocket.getInputStream()' on a null object reference at anywheresoftware.b4a.objects.Serial.getInputStream(Serial.java:256) at anywheresoftware.b4a.samples.bluetooth.chatactivity._activity_create(chatactivity.java:361) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144) at anywheresoftware.b4a.samples.bluetooth.chatactivity.afterFirstLayout(chatactivity.java:104) at anywheresoftware.b4a.samples.bluetooth.chatactivity.access$000(chatactivity.java:17) at anywheresoftware.b4a.samples.bluetooth.chatactivity$WaitForLayout.run(chatactivity.java:82) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:227) at android.app.ActivityThread.main(ActivityThread.java:6100) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:961) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:822) ** Activity (chatactivity) Resume ** .
Erel B4X founder Staff member Licensed User Longtime User Mar 5, 2019 #4 Please upload the project (File - Export as zip) Upvote 0
T TomKluz Active Member Licensed User Longtime User Mar 5, 2019 #5 Mr Erel, Here it is. Kind regards TomKluz Attachments Chat_AsyncStreamText.zip Chat_AsyncStreamText.zip 10.3 KB · Views: 452 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 5, 2019 #6 Your code cannot work. There is no relation between the variable named serial1 in ChatActivity and the variable with the same name in the Main activity. Delete the serial1 variable from the chatactivity. It only causes confusion. Code: AStream.Initialize(Me, "AStream", Main.serial1.InputStream, Main.serial1.OutputStream) Upvote 0
Your code cannot work. There is no relation between the variable named serial1 in ChatActivity and the variable with the same name in the Main activity. Delete the serial1 variable from the chatactivity. It only causes confusion. Code: AStream.Initialize(Me, "AStream", Main.serial1.InputStream, Main.serial1.OutputStream)
T TomKluz Active Member Licensed User Longtime User Mar 5, 2019 #7 I have tryed, but if I remove a declaration of serial1 ("Public serial1 As Serial") from Chatactivity then immediatelly appears an error "Undeclared variable 'serial1' is used before it was assigned any value". In case of AStream initialized in prefix or nonprefix mode it works but in case of text mode this error appears. May I ask you for remedy ? Kind regards TomKluz Upvote 0
I have tryed, but if I remove a declaration of serial1 ("Public serial1 As Serial") from Chatactivity then immediatelly appears an error "Undeclared variable 'serial1' is used before it was assigned any value". In case of AStream initialized in prefix or nonprefix mode it works but in case of text mode this error appears. May I ask you for remedy ? Kind regards TomKluz
DonManfred Expert Licensed User Longtime User Mar 5, 2019 #8 TomKluz said: I have tryed, but if I remove a declaration of serial1 ("Public serial1 As Serial") from Chatactivity then immediatelly appears an error "Undeclared variable 'serial1' is used before it was assigned any value". Click to expand... AND you DID changed the use variable from serial1 to Main.serial1 in the chatactivity??? Upvote 0
TomKluz said: I have tryed, but if I remove a declaration of serial1 ("Public serial1 As Serial") from Chatactivity then immediatelly appears an error "Undeclared variable 'serial1' is used before it was assigned any value". Click to expand... AND you DID changed the use variable from serial1 to Main.serial1 in the chatactivity???
T TomKluz Active Member Licensed User Longtime User Mar 5, 2019 #9 No I didn't changed anything. At first I have changed only declaration and initalisation of AStream mode from prefix to text. And then this foult appears. TomKluz Upvote 0
No I didn't changed anything. At first I have changed only declaration and initalisation of AStream mode from prefix to text. And then this foult appears. TomKluz
Erel B4X founder Staff member Licensed User Longtime User Mar 6, 2019 #10 Please upload the updated project if it is not working. Upvote 0
T TomKluz Active Member Licensed User Longtime User Mar 6, 2019 #11 Mr Erel, I was trying to upload this project many times, but as a resut running is immediatelly blocked by error of "Undeclared variable 'serial1' is used before it was assigned any value". The only change was your suggestion of deleting one line of serial1 declaration from Chatactivity. As I wrote in case of prefix mode of AStream it works. In case of text mode not. Would you be so kind to try to do it also with a code I have sent you. I can'y explain it in better way. Perhaps I am doing something wrong, but I don't now what. Thank you in advance TomKluz Upvote 0
Mr Erel, I was trying to upload this project many times, but as a resut running is immediatelly blocked by error of "Undeclared variable 'serial1' is used before it was assigned any value". The only change was your suggestion of deleting one line of serial1 declaration from Chatactivity. As I wrote in case of prefix mode of AStream it works. In case of text mode not. Would you be so kind to try to do it also with a code I have sent you. I can'y explain it in better way. Perhaps I am doing something wrong, but I don't now what. Thank you in advance TomKluz
Erel B4X founder Staff member Licensed User Longtime User Mar 6, 2019 #12 How can I try it if you are not uploading the updated project? TomKluz said: The only change was your suggestion of deleting one line of serial1 declaration from Chatactivity. Click to expand... This wasn't what I suggested. You should change the initialize line to reference Main.serial1. Upvote 0
How can I try it if you are not uploading the updated project? TomKluz said: The only change was your suggestion of deleting one line of serial1 declaration from Chatactivity. Click to expand... This wasn't what I suggested. You should change the initialize line to reference Main.serial1.
T TomKluz Active Member Licensed User Longtime User Mar 6, 2019 #13 Mr Erel, From where I have to upload the project ? Again your oryginal chat example ? TomKluz Upvote 0
OliverA Expert Licensed User Longtime User Mar 6, 2019 #14 1) More people than @Erel may help you if you don't address everything directly to one person (it is a forum) 2) Upload what you have, since that is what you are having issues with Upvote 0
1) More people than @Erel may help you if you don't address everything directly to one person (it is a forum) 2) Upload what you have, since that is what you are having issues with
T TomKluz Active Member Licensed User Longtime User Mar 6, 2019 #15 I have uploaded again and something is going on. Values from Arduino (so far only in Log panel) of B4A has at last appear ! Thank you very much. I am not addresing everything to @Erel only. He has been replying, so I have been also replying to him. I would like to meet more people on this forum. Hoping that Mr OliverA will forgive me. I am a bigginer here and feel myself like an elefant in pocelain store. TomKluz Upvote 0
I have uploaded again and something is going on. Values from Arduino (so far only in Log panel) of B4A has at last appear ! Thank you very much. I am not addresing everything to @Erel only. He has been replying, so I have been also replying to him. I would like to meet more people on this forum. Hoping that Mr OliverA will forgive me. I am a bigginer here and feel myself like an elefant in pocelain store. TomKluz
T TomKluz Active Member Licensed User Longtime User Mar 6, 2019 #16 By the way, I getting this worning in Log panel:"Recomended value for androidSDK Version is 26 or above (manifest editor) (worning #31)" May I ask what does it mean ? TomKluz Upvote 0
By the way, I getting this worning in Log panel:"Recomended value for androidSDK Version is 26 or above (manifest editor) (worning #31)" May I ask what does it mean ? TomKluz
OliverA Expert Licensed User Longtime User Mar 6, 2019 #17 TomKluz said: May I ask what does it mean ? Click to expand... https://www.b4x.com/android/forum/threads/android-jar-targetsdkversion-minsdkversion.87610/#content Upvote 0
TomKluz said: May I ask what does it mean ? Click to expand... https://www.b4x.com/android/forum/threads/android-jar-targetsdkversion-minsdkversion.87610/#content
OliverA Expert Licensed User Longtime User Mar 6, 2019 #18 After reading the above link, please notice that many of the examples on this forum have been created before the time frame of the link and you may have to update the targetSDKVersion in the manifest. Some applications may even break then (some things do not quite work like they used to), but most of the information on updating apps can be found on the forum. Update: If you were helped, please use the "Like" button to let people know! Oh yea, welcome! Upvote 0
After reading the above link, please notice that many of the examples on this forum have been created before the time frame of the link and you may have to update the targetSDKVersion in the manifest. Some applications may even break then (some things do not quite work like they used to), but most of the information on updating apps can be found on the forum. Update: If you were helped, please use the "Like" button to let people know! Oh yea, welcome!
T TomKluz Active Member Licensed User Longtime User Mar 6, 2019 #19 Thanks a lot for the ansver. How can I check which sdk version I currently have ? Upvote 0
OliverA Expert Licensed User Longtime User Mar 6, 2019 #20 In B4A, Tools->SDK Manager. In the B4A Sdk Manager window that pops up, start typing in android sdk Click to expand... in the search box and see what platform(s) you have installed under the Installed section. In my case, I have 24 (Version 2) and 27 (Version 1). Upvote 0
In B4A, Tools->SDK Manager. In the B4A Sdk Manager window that pops up, start typing in android sdk Click to expand... in the search box and see what platform(s) you have installed under the Installed section. In my case, I have 24 (Version 2) and 27 (Version 1).