I have created a app which need to be worked in work profile in android phone. I need to upload image from Gallery(there is no gallery app or photos app available for work profile). For personal profile same app works fine but for work profile it doesn't.
targetSDKVersion 33 I have applied following code in Manifest file.
<queries>
<!-- Camera -->
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<!-- Gallery -->
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="image/*" />
</intent>
<intent>
<action android:name="android.intent.action.PICK" />
<data android:mimeType="image/*" />
</intent>
<intent>
<action android:name="android.intent.action.CHOOSER" />
</intent>
</queries>
Also have provided this permission.
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
But unfortunately following code return an empty list in work profile app but not an empty list in personal profile app.
packageManager?.queryIntentActivities(intent, 0)
Please help me in making this work. Thanks in advance.
First, Android does not have a
CROPIntent. You are relying on an undocumented and unsupportedIntentaction that only exists on some devices.Second, if you are supplying content to another app, it is your job to supply a concrete MIME type, not a wildcard (
image/*).Third, none of your
<queries>declarations matches yourIntent. If you are getting any results back, it is by happy accident.Fourth, even if your device does support a
CROPIntent, it might not be available in the work profile.There are many image cropping libraries available for Android. Please use one. That will avoid all of these problems.