gpt4 book ai didi

从 sqlite 读取值时出现 Android Stackoverflow 错误

转载 作者:行者123 更新时间:2023-11-29 02:30:56 27 4
gpt4 key购买 nike

我正在使用指纹读取器读取员工指纹。一旦执行了 morphoDatabase.identify,指纹读取器就会等待员工指纹。捕获指纹后,我从指纹读取器数据库中获取 employeeId。现在我想从我的 sqlite 数据库中获取这个员工的详细信息并显示问候语。在此之后,我重新开始识别过程。

问题:当我的识别计数达到大约 100 时,我的应用程序崩溃了。

我添加了 logcat 错误。

Thread commandThread = (new Thread(new Runnable() {
@Override
public void run() {
try {
identifyThreadMethod();
Log.e("Identification Thread", "Completed");
return;
} catch (Exception e) {
e.printStackTrace();
}
}
}));



private void identifyThreadMethod() {

int ret = 0;
try {
ret = morphoDatabase.identify(timeout, far, coder,
detectModeChoice, matchingStrategy, callbackCmd,
DashboardActivity.this, resultMatching, 2, morphoUser);
} catch (Exception e) {
Log.e("Exception", "Identification");
}

if(ret == 0) {
String employeeId= morphoUser.getField(0);
getEmployee(employeeId);
}

if (retvalue != -11) { // reader database not empty
if (!flag) {
identifyThreadMethod();
}
}
}


}

}




public Employee getEmployee(String id) {

if(db == null) {
db = this.getReadableDatabase();
}

String selectQuery = "SELECT * FROM " + TABLE_EMPLOYEE + " WHERE "
+ KEY_ID + "='" + id + "' AND " + KEY_IS_DELETED + "= 0";

//getting stackoverflow error on bellow mentioned line

Cursor cursor = db.rawQuery(selectQuery, null);

if (cursor != null)
cursor.moveToFirst();

if (cursor.getCount() > 0) {
Employee employee = new Employee();
employee.setId(cursor.getString(1));


HashMap<Integer, String> templates = new HashMap<>();
templates.put(1, cursor.getString(2));
templates.put(2, cursor.getString(3));
templates.put(3, cursor.getString(4));
templates.put(4, cursor.getString(5));
templates.put(5, cursor.getString(6));
templates.put(6, cursor.getString(7));
templates.put(7, cursor.getString(8));
templates.put(8, cursor.getString(9));
templates.put(9, cursor.getString(10));
templates.put(10, cursor.getString(11));

employee.setTemplateMap(templates);
employee.setFirstName(cursor.getString(12));
employee.setLastName(cursor.getString(13));
employee.setEmpLevel(cursor.getString(14));
employee.setEmpIndex(cursor.getInt(15));
employee.setEmpPIN(cursor.getString(16));
employee.setEmpAccessMode(cursor.getInt(17));

employee.setEmpEnrollFlag(cursor.getInt(18));
employee.setAuthMode(cursor.getInt(19));
employee.setIsDeleted(cursor.getInt(20));

return employee;
}
return null;
}

错误日志

E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
java.lang.StackOverflowError
at java.util.WeakHashMap.poll(WeakHashMap.java:569)
at java.util.WeakHashMap.put(WeakHashMap.java:608)
at android.database.sqlite.SQLiteConnectionPool.finishAcquireConnectionLocked(SQLiteConnectionPool.java:911)
at android.database.sqlite.SQLiteConnectionPool.tryAcquirePrimaryConnectionLocked(SQLiteConnectionPool.java:847)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:613)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:586)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
at com.cms.attendance.fingerprintreader.database.DatabaseHandler.getEmployee(DatabaseHandler.java:434)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:876)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThreadMethod(DashboardActivity.java:999)
at com.cms.attendance.fingerprintreader.newui.DashboardActivity.identifyThrea

最佳答案

if (retvalue != -11) { // reader database not empty
if (!flag) {
identifyThreadMethod();
}
}

似乎总是满足这个条件,因此 identifyThreadMethod();总是被称为递归。

关于从 sqlite 读取值时出现 Android Stackoverflow 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49644780/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com