Skip to content
Snippets Groups Projects
Commit 32ee1824 authored by Greyson Parrelli's avatar Greyson Parrelli
Browse files

Fix crash that occurs if we don't have permission to add an account.

parent cd10aa90
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,7 @@ object SystemContactsRepository {
var account: Account? = if (accounts.isNotEmpty()) accounts[0] else null
if (account == null) {
try {
Log.i(TAG, "Attempting to create a new account...")
val newAccount = Account(accountDisplayName, applicationId)
......@@ -97,6 +98,9 @@ object SystemContactsRepository {
} else {
Log.w(TAG, "Failed to create a new account!")
}
} catch (e: SecurityException) {
Log.w(TAG, "Failed to add an account.", e)
}
}
if (account != null && !ContentResolver.getSyncAutomatically(account, ContactsContract.AUTHORITY)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment