Guest User

Untitled

a guest
Sep 1st, 2020
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. fun songChange(v: View){
  2. file = Intent(Intent.ACTION_GET_CONTENT)
  3. file.setType("audio/*")
  4. startActivityForResult(file, 10)
  5.  
  6. }
  7.  
  8. override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  9. super.onActivityResult(requestCode, resultCode, data)
  10.  
  11. when(resultCode){
  12. RESULT_OK ->
  13. {
  14. val uploadSong = "http://.."
  15. val params = RequestParams()
  16. var songFile = File(data?.data.toString())
  17. try {
  18. params.put("song", songFile)
  19. } catch (e: FileNotFoundException) {
  20.  
  21. Log.d("ERROR", data?.data.toString())
  22. Log.d("ERROR", songFile.isFile().toString())
  23. }
  24.  
  25. val client = AsyncHttpClient()
  26. client.post(uploadSong, params, object : AsyncHttpResponseHandler() {
  27. override fun onStart() {
  28. // called before request is started
  29. }
  30.  
  31. override fun onSuccess(
  32. statusCode: Int,
  33. headers: Array<Header>,
  34. response: ByteArray
  35. ) {
  36. // called when response HTTP status is "200 OK"
  37.  
  38. }
  39.  
  40. })
  41.  
Add Comment
Please, Sign In to add comment