Remove Contact select option form file select options
Asked Answered
S

3

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

Segregate answered 15/3, 2016 at 10:55 Comment(2)
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.Atabrine
Thanks @Atabrine 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.Segregate
B
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);
Bicapsular answered 16/3, 2016 at 8:13 Comment(1)
Thanks @Bicapsular helpful.Segregate
N
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/*");
Norby answered 15/3, 2016 at 11:23 Comment(4)
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.Segregate
Eg. "text/*" offers Google Drive as an option. Is GDrive in that Genymotion emulator installed?Norby
I am using my device, but it is not allow ing to select files lilse, Like Image, pdf etc.Segregate
I'm afraid you must write your own logic that will recognise what files must be opened with which apps/intents.Norby
M
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);
Mousse answered 15/3, 2016 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.