You want to use a http request to send data and files to a web server. Typical example of it would be editing your profile on a social network, you're sending both data and -usually- a file (your avatar).
Following snippet should be within an AsyncTask or similar, it must not be within the UI thread, for latest Android versions will simply kill your app if you do http requests on the main UI thread.
public void add_file() {
file_sel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, PICKFILE_RESULT_CODE);
/* choose_filecr=filepath.getText().toString();
if(choose_filecr.isEmpty())
{
filepath.setError("Please choose file");
valid=false;
}
else
{
filepath.setVisibility(View.GONE);
choose_filecr="N/A";
}*/
}
});
}
Comments
Post a Comment