Can we use Intent.EXTRA_ALLOW_MULTIPLE for older v

2019-04-29 21:15发布

问题:

According to Intent.EXTRA_ALLOW_MULTIPLE documentation:

Used to indicate that a ACTION_GET_CONTENT intent can allow the user to select and return multiple items. This is a boolean extra; the default is false. If true, an implementation of ACTION_GET_CONTENT is allowed to present the user with a UI where they can pick multiple items that are all returned to the caller. When this happens, they should be returned as the getClipData() part of the result Intent.

So we can use it as:

startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true).setType("image/*");

But this is available for Android API 18+ only.

So my question is can we use it for older versions of Android API levels using Android Support Library?

If yes, How?

回答1:

can we use it for older versions of Android API levels using Android Support Library?

No, we can't, Intent.EXTRA_ALLOW_MULTIPLE is not included in the Android Support Library, at least at this moment.



回答2:

I'm afraid you can not use it before API 16. Because to use this you will be required to call getClipData() to get multiple paths/URIs, getClipData was added in API 16. But its better to use from API 18.