Merge pull request #1116 from pfaffenrodt/feature/pick-image-file

Add support to pick image from content provider
This commit is contained in:
Sylvia van Os
2022-11-22 19:04:48 +01:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

@@ -228,8 +228,13 @@ public class ScanActivity extends CatimaAppCompatActivity {
public void addFromImage(View view) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
Intent contentIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(photoPickerIntent, getString(R.string.addFromImage));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { contentIntent });
try {
photoPickerLauncher.launch(photoPickerIntent);
photoPickerLauncher.launch(chooserIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), R.string.failedLaunchingPhotoPicker, Toast.LENGTH_LONG).show();
Log.e(TAG, "No activity found to handle intent", e);