Android Question Bluetooth chat example don't want to start

Status
Not open for further replies.

TomKluz

Active Member
Licensed User
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

TomKluz

Active Member
Licensed User
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 **

.
 

TomKluz

Active Member
Licensed User
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
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".
AND you DID changed the use variable from serial1 to Main.serial1 in the chatactivity???
 

TomKluz

Active Member
Licensed User
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
 

TomKluz

Active Member
Licensed User
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
 

TomKluz

Active Member
Licensed User
Mr Erel,

From where I have to upload the project ? Again your oryginal chat example ?

TomKluz
 

OliverA

Expert
Licensed User
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
 

TomKluz

Active Member
Licensed User
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
 

TomKluz

Active Member
Licensed User
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
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!
 

OliverA

Expert
Licensed User
In B4A, Tools->SDK Manager. In the B4A Sdk Manager window that pops up, start typing in
android sdk
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).
 
Status
Not open for further replies.
Top