Android Question problem on restarting audio recorder

RichyK68

Active Member
Licensed User
Longtime User
Hi all,

The following code runs fine the first time, but when you press the back button to close the app, then go back into the app, it errors with java.lang.RuntimeException: start failed.

How do I re-initialize the object after it stops listening in the _Pause event?

Richard

B4X:
'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim T As Timer
    Dim A As AudioRecorder

End Sub

Sub Activity_Create(FirstTime As Boolean)
   
    'Calls sub AmplitudeCheck every 500 milliseconds

    A.Initialize 
    A.AudioSource=A.AS_MIC
    A.OutputFormat=A.OF_THREE_GPP
    A.AudioEncoder=A.AE_AMR_NB
    A.setOutputFile("","/dev/null")
    A.prepare       
    a.start

    T.Initialize("AmplitudeCheck",500)
   
End Sub

Sub Activity_Resume

    'Set up recorder

    T.Enabled=True

End Sub

Sub Activity_Pause (UserClosed As Boolean)

    T.Enabled=False
    A.stop
   
End Sub

Sub AmplitudeCheck_tick
   
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…