My application adds to the contact list of user. I want incoming calls from these user to play a non-standard melody. New user appear in the contact list. After I use the service SetCustomRingtone from the class ContactsUtils to set a custom ringtone. The process runs without errors, but these users in contacts have no any things ringtone. For all the play standart ringtone.
in class module...
in activity module...
in class module...
B4X:
'Inserts a new contact and returns the cuContact object of this contact.
Public Sub InsertContact(Name As String, Phone As String, Email As String, Note As String, Company As String) As cuContact
Dim values As ContentValues
values.Initialize
values.PutNull("account_name")
values.PutNull("account_type")
Dim rawUri As Uri = cr.Insert(rawContactUri, values)
Dim rawContactId As Long = rawUri.ParseId
values.Initialize
values.PutLong("raw_contact_id", rawContactId)
values.PutString("mimetype", "vnd.android.cursor.item/phone_v2")
values.PutString("data1", Phone)
cr.Insert(dataUri, values)
values.Initialize
values.PutLong("raw_contact_id", rawContactId)
values.PutString("mimetype", "vnd.android.cursor.item/name")
values.PutString("data1", Name)
cr.Insert(dataUri, values)
values.Initialize
values.PutLong("raw_contact_id", rawContactId)
values.PutString("mimetype", "vnd.android.cursor.item/email_v2")
values.PutString("data1", Email)
cr.Insert(dataUri, values)
values.Initialize
values.PutLong("raw_contact_id", rawContactId)
values.PutString("mimetype", "vnd.android.cursor.item/note")
values.PutString("data1", Note)
cr.Insert(dataUri, values)
values.Initialize
values.PutLong("raw_contact_id", rawContactId)
values.PutString("mimetype", "vnd.android.cursor.item/organization")
values.PutString("data1", Company)
cr.Insert(dataUri, values)
Dim cu As cuContact
cu.Initialize
Dim crsr As Cursor = cr.Query(dataUri, Array As String("contact_id", "display_name"), "raw_contact_id = ?", _
Array As String(rawContactId), "")
crsr.Position = 0
cu.DisplayName = crsr.GetString("display_name")
cu.Id = crsr.GetLong("contact_id")
'
' Dim values As ContentValues
' values.Initialize
' values.PutString("custom_ringtone", RingtoneURI)
' cr.Update(contactUri, values, "_id = ?", Array As String(Id))
'' Log("MP3 " & RingtoneURI)
Return cu
End Sub
in activity module...
B4X:
Cont=Main.CU.InsertContact("VALERA", "+77013503350", "[email protected]", "GURU", "INFORMBYURO")
strPath=GetPathFromContentResult(File.Combine(File.DirInternal,"rington.mp3"))
Main.CU.SetCustomRingtone(Cont.Id, strPath)