It´s my first app with implicit intent and i´m trying to work with it with my books and android referenz for kotlin.
Now i got a problem on working with the result of an intent.
- i created a button
- OnClick at the button it starts "startActivityForResult" and opens the intent of the RingtoneManager
- Now i can choose the sound.
Everything is fine to this step. Now i read, that i have to use the "onActivityResult"-function to get the uri of the sound and then can use the uri to start the ringtone.
I just dont know how to get the this uri. "OnActiviyResult" gives a parameter with data. The data is an intent. I think i have to get the uri out of the data of the intent, but i dont know really how. Could someone help me pls, or just give me a hint? I don´t need the full solution. A hint would really help me.
// starts on Using the Intent
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Log.i("onActivityResult", "Start")
val ringtoneTaken : Boolean = false
super.onActivityResult(requestCode, resultCode, data)
//val uri? : URI =
//val uri = data.toUri()
if(requestCode == 999 && resultCode == RESULT_OK) {
if(data != null) {
}
}
//saveSelectedRingtone()
}
}
Ok i finally found the answer now. It´s working with :
then i can set the new ringtone with
and start playing it.