Skip to content

Commit

Permalink
Merge pull request #157 from rahulraj-idt/fix-android-crash-open-exte…
Browse files Browse the repository at this point in the history
…rnal-view

Fix #156 - openExternalInsert() causing android app crash
  • Loading branch information
joachim-quis authored May 27, 2024
2 parents ddcdff9 + f23d743 commit b52126f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ class FlutterContactsPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Str
// content://com.android.contacts/raw_contacts/<raw_id>
// So we need to get the ID from the raw ID.
val rawId = intent?.getData()?.getLastPathSegment()
if (rawId != null) {
val readPermission = Manifest.permission.READ_CONTACTS
val hasContactsReadPermission = ContextCompat.checkSelfPermission(
context!!, readPermission
) == PackageManager.PERMISSION_GRANTED
if (rawId != null && hasContactsReadPermission) {
// Check the contacts read permission since 'open external insert' can be
// called even without contacts permission. So while selecting contacts, be sure
// that we have read permission.
val contacts: List<Map<String, Any?>> =
FlutterContacts.select(
resolver!!,
Expand Down

0 comments on commit b52126f

Please sign in to comment.