I am getting Geodatabase is closed error. Below are callstack of error :-
com.esri.arcgisruntime.ArcGISRuntimeException: Geodatabase is closed.
at com.esri.arcgisruntime.internal.jni.CoreFeatureQueryResult.nativeIterator(Native Method)
at com.esri.arcgisruntime.internal.jni.CoreFeatureQueryResult.g(SourceFile:1)
at com.esri.arcgisruntime.data.FeatureQueryResult.iterator(SourceFile:4)
at aqmddev.aqmd.gov.scaqmdmobile.viewmodel.BaseViewModel.argGISService$lambda-4(BaseViewModel.kt:167)
at aqmddev.aqmd.gov.scaqmdmobile.viewmodel.BaseViewModel.$r8$lambda$DUDWFHLmsJ9MT2R8rukbngwex7g(Unknown Source:0)
at aqmddev.aqmd.gov.scaqmdmobile.viewmodel.BaseViewModel$$ExternalSyntheticLambda0.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Here is my source code :-
protected fun argGISService(params: QueryParameters, url: String, response: (Int, feature: Set<Feature>?) -> Unit){
try{
// set all outfields
val outFields = arrayListOf<String>()
outFields.add("*")
params.isReturnGeometry = true
mServiceFeatureTable = ServiceFeatureTable(url)
mServiceFeatureTable!!.featureRequestMode = ServiceFeatureTable.FeatureRequestMode.MANUAL_CACHE
//populate the table based on the query, listen for result in a listenable future
//query feature from the table
val future = mServiceFeatureTable!!.populateFromServiceAsync(params, true, outFields)
future.addDoneListener {
try {
//call get on the future to get the result
val result = future.get()
val features = result.iterator().asSequence().toSet()
if (features != null && !features.isNullOrEmpty()) {
response(features.count(), features)
}else{
response(0, null)
}
}catch (e: Exception) {
response(0, null)
LogUtils.e("BaseFragment", "Populate from service failed 2: " + e.printStackTrace())
}catch (ex: RuntimeException){
LogUtils.e("BaseFragment", "runtime execptionPopulate from service failed 2: " + ex.printStackTrace())
ex.printStackTrace()
response(0, null)
}
}
}catch (e1: Exception){
e1.printStackTrace()
response(0, null)
}catch (ex2: RuntimeException){
ex2.printStackTrace()
response(0, null)
}
}