Android:How to upload .mp3 file to http server?

前端 未结 4 1759
轮回少年
轮回少年 2020-11-29 17:42

I want to upload .mp3 file(only) from device to my server.

I want to browse path of media data and select any mp3 file and upload it.

4条回答
  •  囚心锁ツ
    2020-11-29 17:55

    I know this was asked a while aback. I was trying to implement the same and after trying many solutions I found that @Keaton 's code is working for me, but it was blocking my UI (I am using Android Studio 2.1.2), so I had to wrap it in an AsyncTask.

    So using @Keaton 's code I have this.

    From my onClickListener()

    private View.OnClickListener btnUpload = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new doFileUpload().execute();
        }
    };
    

    Then the AsyncTask

    public class doFileUpload extends AsyncTask {
    
        @Override
        protected Void doInBackground(Void... params) {
    
            
    
         return null;
       }
    }
    

    I hope this helps to anybody having the same problem I had.

提交回复
热议问题