Fix for 'Crash on clicking "Add from image" button in scan activity #856'

This commit is contained in:
Alajemba
2022-06-28 06:33:10 +00:00
parent 88d27c0385
commit 4f7f72f213
2 changed files with 8 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package protect.card_locker;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
@@ -206,6 +207,11 @@ public class ScanActivity extends CatimaAppCompatActivity {
public void addFromImage(View view) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
photoPickerLauncher.launch(photoPickerIntent);
try {
photoPickerLauncher.launch(photoPickerIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), R.string.failedLaunchingPhotoPicker, Toast.LENGTH_LONG).show();
Log.e(TAG, "No activity found to handle intent", e);
}
}
}