Android Question Stop a ringtone

sixvoz

Member
Licensed User
Longtime User
Hi, can someone give me info and sample on how stop a ringtone?
B4X:
   Dim jo As JavaObject
   jo.InitializeStatic("android.media.RingtoneManager")
   Dim jo2 As JavaObject
   jo2.InitializeContext
   Dim u As Uri
   u.Parse(rm.GetDefault(rm.TYPE_RINGTONE))
   ringtone =jo.RunMethodJO("getRingtone", Array(jo2, u))
   'jo.RunMethod("stopPreviousRingtone", Null)
   ringtone.RunMethod("stop", Null)

This Not stop the ringtone.

Help please.

Thank you.
 

DonManfred

Expert
Licensed User
Longtime User
I guess it must be something like (but i can be wrong)
B4X:
dim rt as JavaObject
rt = rm.GetDefault(rm.TYPE_RINGTONE)
[...]
rt.play
rt.stop
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Dim jo As JavaObject
jo.InitializeStatic("android.media.RingtoneManager")
Dim jo2 As JavaObject
jo2.InitializeContext
Dim u As Uri
u.Parse(rm.GetDefault(rm.TYPE_RINGTONE))
ringtone =jo.RunMethodJO(
"getRingtone", Array(jo2, u))
'jo.RunMethod("stopPreviousRingtone", Null)
ringtone.RunMethod("stop", Null)

Just use only

B4X:
ringtone.RunMethod("stop", Null)

Important: Must be the same ringtone object which started the ringtone to play (NOT a new instance which you have created here).
 
Upvote 0

Similar Threads

Top