Android Question Public variables

Kiran Raotole

Active Member
Licensed User
I want to declared public variables which i can access from any modules.
I'm new in B4A.

Thanks in advance
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Kiran Raotole

Active Member
Licensed User

i try Public abcd ="xyz" As String

but it show error :

Logger connected to: Xiaomi Mi A1
--------- beginning of crash
--------- beginning of system
--------- beginning of main
java.lang.RuntimeException: Unable to create service b4a.example.starter: java.lang.RuntimeException: java.net.SocketException: Connection reset
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3428)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1695)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.RuntimeException: java.net.SocketException: Connection reset
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
at b4a.example.starter.onCreate(starter.java:48)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3418)
... 8 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:139)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
at java.io.BufferedInputStream.read(BufferedInputStream.java:267)
at java.io.DataInputStream.readByte(DataInputStream.java:268)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:353)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
... 10 more
java.lang.RuntimeException: Unable to create service b4a.example.starter: java.lang.RuntimeException: java.net.SocketException: Connection reset
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3428)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1695)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.RuntimeException: java.net.SocketException: Connection reset
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
at b4a.example.starter.onCreate(starter.java:48)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3418)
... 8 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:139)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
at java.io.BufferedInputStream.read(BufferedInputStream.java:267)
at java.io.DataInputStream.readByte(DataInputStream.java:268)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:353)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
... 10 more
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Starter Service
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public abcd As String ' Only declaration
End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    abcd ="xyz" ' Setting the Value
End Sub
 
Upvote 0
Top