9

I am opening file pick Intent with, Bellow code

Intent intent_upload = new Intent();
    intent_upload.setType("*/*");
    intent_upload.setAction(Intent.ACTION_GET_CONTENT);
    activity.startActivityForResult(intent_upload, Constants.FILE_PICK_REQUEST_CODE);

I Want remove Contact option from list, please can anyone help.

Thanksenter image description here

Abdelilah El Aissaoui
  • 4,204
  • 2
  • 27
  • 47
Jogendra Gouda
  • 405
  • 4
  • 17
  • You are asking for all types of content (`*/*`). Contacts are a type of content. If you do not want contacts, do not ask for `*/*` for a MIME type. – CommonsWare Mar 15 '16 at 11:18
  • Thanks @CommonsWare for Quick replay, If I not ask for "*/*" it is not allowing me to select files available in google drive. Making those files disable for selection. – Jogendra Gouda Mar 15 '16 at 11:23

3 Answers3

4

Use below code I think it can help you and also refers Link

Intent intent_upload = new Intent();
        intent_upload.setType("*/*");
        intent_upload.setAction(Intent.ACTION_GET_CONTENT);
        intent_upload.addCategory(Intent.CATEGORY_OPENABLE);
        activity.startActivityForResult(intent_upload, Constants.FILE_PICK_REQUEST_CODE);
hharry_tech
  • 952
  • 1
  • 8
  • 24
0

You need to specify what type of intent (apps) you want to open. Now you set offer me all apps:

intent_upload.setType("*/*"); 

This can be different type for images, music, documents etc. eg.:

intent.setType("image/*");
Honza Musil
  • 320
  • 2
  • 10
  • intent_upload.setType("image/*"); String[] mimeTypes = {"audio/*", "video/*", "text/*", "application/*", "multipart/*", "message/*", "model/*"}; I am using this for all file types. But it is not allowing me to select files available in google Drive. – Jogendra Gouda Mar 15 '16 at 11:26
  • Eg. "text/*" offers Google Drive as an option. Is GDrive in that Genymotion emulator installed? – Honza Musil Mar 15 '16 at 11:33
  • I am using my device, but it is not allow ing to select files lilse, Like Image, pdf etc. – Jogendra Gouda Mar 15 '16 at 11:40
  • I'm afraid you must write your own logic that will recognise what files must be opened with which apps/intents. – Honza Musil Mar 15 '16 at 14:36
0

As CommonsWare said you don't have alternatives than setting the specific MIME_TYPES and ignore using "*/*". Use specified MIME_TYPES like here..

    String[] mimetypes = {"image/*", "video/*"};
    Intent intent_upload = new Intent();
    intent_upload.setType("image/*,video/*");
    intent_upload.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
    intent_upload.setAction(Intent.ACTION_GET_CONTENT);
    MainActivity.this.startActivityForResult(intent_upload, Constants.FILE_PICK_REQUEST_CODE);
Shree Krishna
  • 8,474
  • 6
  • 40
  • 68