Fix crash for call log item without number

This commit is contained in:
xynngh 2020-07-08 12:30:07 +04:00
parent 535680196c
commit f932e391af
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils;
public class ContactsHelper { public class ContactsHelper {
@ -13,6 +14,8 @@ public class ContactsHelper {
}; };
public static String getContactName(Context context, String number) { public static String getContactName(Context context, String number) {
if (TextUtils.isEmpty(number)) return null;
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(number)); Uri.encode(number));