Android Question RingerMode and AI hint code

Elric

Well-Known Member
Licensed User
Hello everyone!

I've asked a couple of thing to Gemini 3.0 and it suggest to change this code:
B4X:
    'RINGER_SILENT = 0
    'RINGER_VIBRATE = 1
    'RINGER_NORMAL = 2 Audible & Vibrate
    dim mPhone as Phone
    mPhone.SetRingerMode(mPhone.RINGER_SILENT)
in this code
B4X:
    Try
        Dim myjoContext As JavaObject
        myjoContext.InitializeContext
        
        Dim myjoAudio As JavaObject = myjoContext.RunMethod("getSystemService", Array("audio"))
        
        ' 0 = RINGER_SILENT
        myjoAudio.RunMethod("setRingerMode", Array(0)) ' or Array(1) for RINGER_VIBRATE or Array (2) for RINGER__NORMAL
        
    Catch
        LastException.Message
    End Try
because it is renow by every or almost every phone.

I've tried AI and sometimes give good hints some other it is a terrible coding assistant!

Should I follow this hint? What do you think?

Thanks!
 

sirjo66

Well-Known Member
Licensed User
Longtime User
B4X:
Public Ph As Phone


Sub SilenziaTelefono
    Try
        Ph.SetRingerMode(Ph.RINGER_SILENT)
    Catch
        Log(LastException)
    End Try
End Sub

Sub RipristinaSuoneria(Modo As Int)
    Try
        Ph.SetRingerMode(Modo)
    Catch
        Log(LastException)
    End Try
End Sub

Yes, this code works very well, I use it in an app, no problem
 
Upvote 0

Elric

Well-Known Member
Licensed User
Thanks guys!

I'm wondering if in this case I should follow the AI hints because some "far east manufacturer" (as the AI wrote) makes it more difficult than usual or if such hints are just (one of many) "AI fake hints" (as I supppose).
 
Upvote 0
Top