1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question Audio recording problem with the samples

Discussion in 'Android Questions' started by JukkaHo, Apr 20, 2019.

  1. JukkaHo

    JukkaHo Member Licensed User

    Audio recording steamer or to a wave file
    I get this error with both versions:

    java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
    at android.media.AudioRecord.startRecording(AudioRecord.java:1013)
    at anywheresoftware.b4a.audio.AudioStreamer.StartRecording(AudioStreamer.java:98)

    The manifest is:

    AddManifestText(
    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="26"/>
    <supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
    SetApplicationAttribute(android:icon, "@drawable/icon")
    SetApplicationAttribute(android:label, "$LABEL$")
    'End of default text.

    Test device is Huawei P Smart

    thanks
    JukkaHo
     
  2. JohnC

    JohnC Well-Known Member Licensed User

  3. JukkaHo

    JukkaHo Member Licensed User

    Thanks, JohnCody. I'll try with that...
     
  4. PassionDEV

    PassionDEV Active Member Licensed User

  5. JukkaHo

    JukkaHo Member Licensed User

    Thanks PassionDEV,

    As you correctly guessed, the actual problem was with permissions.

    This helped:

    If FirstTime Then
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result<>True Then
    ExitApplication
    End If
    rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result<>True Then
    ExitApplication
    End If


    So these work fine.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. JukkaHo

    JukkaHo Member Licensed User

    Thank you, Erel

    That is neat coding.

    I have been using Basic languages long time, some say too long time since QuickBASIC and later other even
    Visual Basic For DOS and latest .NET versions and around 2000 some Basic for Palm devices
    but B4A has been the most beautiful one.
    It has it's specific approach to coding but very easy to adopt. It is also powerful and easy to extend with Javaobjects and Java parts.
    And you can use your code in other environments easily.
    Logging and B4A Bridge are very useful and nice testing tools.
    The pearl is support which is top of tops with this community!

    thank you
    JukkaHo
     
    Erel and OliverA like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice