Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException #292

Merged
merged 1 commit into from
Dec 14, 2022
Merged

Conversation

ChanakaWeerasinghe
Copy link
Contributor

java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference

java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference
@lukasgit
Copy link
Owner

lukasgit commented Dec 13, 2022 via email

@lukasgit lukasgit merged commit c901a28 into lukasgit:master Dec 14, 2022
@BetterB0y
Copy link

@lukasgit After this one app is not building.

/java/flutter/plugins/contactsservice/contactsservice/ContactsServicePlugin.java:299: error: cannot find symbol
cursor.close();
^
symbol: variable cursor
location: class ContactsServicePlugin.BaseContactsServiceDelegate

@BetterB0y
Copy link

Its caused because cursor variable is not in { }.
Proper code should look like this:

if (intent == null) {
    return true;
}

Cursor cursor = contentResolver.query(contactUri, null, null, null, null);
if (cursor.moveToFirst()) {
    String id = contactUri.getLastPathSegment();
    getContacts("openDeviceContactPicker", id, false, false, false, localizedLabels, this.result);
} else {
    Log.e(LOG_TAG, "onActivityResult - cursor.moveToFirst() returns false");
    finishWithResult(FORM_OPERATION_CANCELED);
}
cursor.close();
return true;

nidegen added a commit to nidegen/flutter_contacts that referenced this pull request Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants