1

i wanna upload files on server from android app. so User can pick any file from recent like image, doc or any PDF in android app and will upload on server.

So please tell me how to open that recent activity and select any file and how to upload it on server.

Please help me this very important for me.

Shivam Nagpal
  • 763
  • 2
  • 9
  • 21

1 Answers1

0

you can use */* for open all files as in android.

Intent intent = new Intent();    
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getString(R.string.perform_action_with)), attachmentChoice);

note:where attachmentChoice is Constant.

John smith
  • 1,781
  • 17
  • 27
  • Can you please tell me how to upload file(Image,PDF,DOC file on server) . should i use multi-part or something else and how will i get to know which file user has selected? – Shivam Nagpal Sep 30 '15 at 05:34
  • dear after selecting any file ,in you onActivityResult() you can create path from URI. then you can get file type from there. public static String getFileType(String path) { String substring = path.substring(path.lastIndexOf("/") + 1); return substring.substring(substring.lastIndexOf(".") + 1); } – John smith Sep 30 '15 at 05:41
  • which is the best way to upload file on server from app? – Shivam Nagpal Sep 30 '15 at 06:02
  • i think use multi-part-service. – John smith Sep 30 '15 at 06:05
  • can i upload doc , pdf or other text files using multi-part? – Shivam Nagpal Sep 30 '15 at 06:25
  • yes dear,see@http://stackoverflow.com/questions/16797468/how-to-send-a-multipart-form-data-post-in-android-with-volley – John smith Sep 30 '15 at 06:36