URISyntaxException:VCard 中索引 0 处的预期方案名称 android
URISyntaxException: Expected scheme name at index 0 in VCard android
我正在使用以下依赖项从设备导出联系人:
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
导出时,用户有时会在 Play 商店的实时应用程序中遇到问题。下面是在 vcard 中添加 impp 对象的代码:
contact.IMs.forEach {mIM->
try {
val mLabel = if(mIM.label.isNullOrEmpty()) mIM.value else mIM.label
val impp = when (mIM.type) {
ContactsContract.CommonDataKinds.Im.PROTOCOL_AIM -> Impp.aim(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_YAHOO -> Impp.yahoo(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_MSN -> Impp.msn(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_ICQ -> Impp.icq(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE -> Impp.skype(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_QQ -> Impp(QQ, mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER -> Impp(JABBER, mIM.value)
else -> Impp(mLabel, mIM.value)
}
card.addImpp(impp)
}catch (e: Exception){
crashlytics.setCustomKey("Contact IMs", "Label: "+mIM.label+" Value: "+mIM.value+" Type: "+mIM.type)
Applog.e(TAG, e)
}
}
在线 card.addImpp(impp)
,我收到以下错误:
Non-fatal Exception: java.lang.Exception: java.lang.IllegalArgumentException: java.net.URISyntaxException: Expected scheme name at index 0: :
at com.allbackup.helpers.Applog.e(Applog.java:20)
at com.allbackup.helpers.VcfExporter.exportContacts(VcfExporter.java:133)
at com.allbackup.workers.WorkerViewModel$backupContactData.invokeSuspend(WorkerViewModel.java:151)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.java:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java:665)
因为我找到了原因。发生这种情况主要是因为标签和值都是空的。
对此有任何帮助吗?
跳过没有价值的即时消息:
contact.IMs.forEach { mIM ->
// skip illegal IMs
if (mIM.value.isNullOrEmpty()) return@forEach
try {
...
} catch (e: Exception) {
...
}
}
我正在使用以下依赖项从设备导出联系人:
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
导出时,用户有时会在 Play 商店的实时应用程序中遇到问题。下面是在 vcard 中添加 impp 对象的代码:
contact.IMs.forEach {mIM->
try {
val mLabel = if(mIM.label.isNullOrEmpty()) mIM.value else mIM.label
val impp = when (mIM.type) {
ContactsContract.CommonDataKinds.Im.PROTOCOL_AIM -> Impp.aim(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_YAHOO -> Impp.yahoo(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_MSN -> Impp.msn(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_ICQ -> Impp.icq(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE -> Impp.skype(mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_QQ -> Impp(QQ, mIM.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER -> Impp(JABBER, mIM.value)
else -> Impp(mLabel, mIM.value)
}
card.addImpp(impp)
}catch (e: Exception){
crashlytics.setCustomKey("Contact IMs", "Label: "+mIM.label+" Value: "+mIM.value+" Type: "+mIM.type)
Applog.e(TAG, e)
}
}
在线 card.addImpp(impp)
,我收到以下错误:
Non-fatal Exception: java.lang.Exception: java.lang.IllegalArgumentException: java.net.URISyntaxException: Expected scheme name at index 0: :
at com.allbackup.helpers.Applog.e(Applog.java:20)
at com.allbackup.helpers.VcfExporter.exportContacts(VcfExporter.java:133)
at com.allbackup.workers.WorkerViewModel$backupContactData.invokeSuspend(WorkerViewModel.java:151)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.java:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java:665)
因为我找到了原因。发生这种情况主要是因为标签和值都是空的。
对此有任何帮助吗?
跳过没有价值的即时消息:
contact.IMs.forEach { mIM ->
// skip illegal IMs
if (mIM.value.isNullOrEmpty()) return@forEach
try {
...
} catch (e: Exception) {
...
}
}