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.
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.