Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun songChange(v: View){
- file = Intent(Intent.ACTION_GET_CONTENT)
- file.setType("audio/*")
- startActivityForResult(file, 10)
- }
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- super.onActivityResult(requestCode, resultCode, data)
- when(resultCode){
- RESULT_OK ->
- {
- val uploadSong = "http://.."
- val params = RequestParams()
- var songFile = File(data?.data.toString())
- try {
- params.put("song", songFile)
- } catch (e: FileNotFoundException) {
- Log.d("ERROR", data?.data.toString())
- Log.d("ERROR", songFile.isFile().toString())
- }
- val client = AsyncHttpClient()
- client.post(uploadSong, params, object : AsyncHttpResponseHandler() {
- override fun onStart() {
- // called before request is started
- }
- override fun onSuccess(
- statusCode: Int,
- headers: Array<Header>,
- response: ByteArray
- ) {
- // called when response HTTP status is "200 OK"
- }
- })
Add Comment
Please, Sign In to add comment