Android Question Please help me.

sami9850564808

New Member
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: False
    #ApplicationLabel: Xyz
    #VersionCode: 1
    #VersionName: 0
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
 
Dim Serial1 As Serial
    Dim TextReader1 As TextReader

    Dim Timer1 As Timer
 
    Dim connected As Boolean
    Dim line As String
    Dim smsdata As String
    Dim Vibrate As PhoneVibrate ' For phone vibration
    Dim Sms As PhoneSms
 
    Dim time As Int
End Sub

Sub Globals
    Dim edittext1 As EditText
        
    Dim Label10 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)

    If FirstTime Then
        Serial1.Initialize("Serial1")
        GPS1.Initialize("GPS")
    End If
 
        Activity.LoadLayout("welcome")
        Activity.AddMenuItem("Connect", "mnuConnect")
        Activity.AddMenuItem("Disconnect", "mnuDisconnect")
        sensor=False
    
        intercept.Initialize2("intercept",999)
End Sub
Sub Activity_Resume

    If Serial1.IsEnabled = False Then
        Msgbox("Please enable Bluetooth.", "")
    Else
        Serial1.Listen 'listen for incoming connections
    End If
 
 
End Sub
Sub mnuConnect_Click

    Dim PairedDevices As Map
    PairedDevices = Serial1.GetPairedDevices
    Dim l As List
    l.Initialize
    For i = 0 To PairedDevices.Size - 1
        l.Add(PairedDevices.GetKeyAt(i))
    Next
 
    Dim res As Int
    res = InputList(l, "Choose device", -1) 'show list with paired devices
    If res <> DialogResponse.CANCEL Then
        Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
    End If
 
End Sub

Sub Serial1_Connected (Success As Boolean)
    If Success Then
        ToastMessageShow("Connected successfully", False)
        TextReader1.Initialize(Serial1.InputStream)
        TextWriter1.Initialize(Serial1.OutputStream)   
        connected = True           
    Else
        connected = False
        Timer1.Enabled = False
        timer2.Enabled = False
        Serial1.Disconnect
        Msgbox(LastException.Message, "Error connecting.")
    End If
End Sub
Sub mnuDisconnect_Click
    Serial1.Disconnect
    connected = False
    GPS1.Stop
End Sub

Sub ImageView1_Click
    Activity.LoadLayout("names")           
End Sub

Sub Panel1_Click
    Activity.LoadLayout("sensor")
 
    Timer1.Initialize("Timer1", 100)
 
 
    Timer1.Enabled = True
 
    time=0
End Sub

Sub Timer1_Tick
 
       time = time + 100
 
       If time > 15000 Then
          Label10.Text="Bag Missing..."
          Vibrate.Vibrate (3000)
          time=0
       End If
  
    If connected Then 
 
        If TextReader1.Ready Then     
        
              line=TextReader1.readline
          
              If line.CharAt(0)="B" Then               
                   Label10.Text="Monitor Panel"
                   time = 0
              
              End If
          
                  
        End If   
    End If
End Sub
 
Last edited:

sami9850564808

New Member
I am not getting option to edit title.
I will explain my problem here,
I have sent code related to bluetoth.I am trying to send one character every 10 sec from micro controller (Aurdiuno) to application what i have developed.
But as soon as microcontroller start sending the data application get hang and stop working.This situation happening only when MCU start transmission.
 
Upvote 0
Top