アプリケーションにアプリのショートカットを実装しています。ショートカットを開こうとすると正常に開きましたが、検索機能中にクラッシュ レポートがクラッシュし、DB からデータをフェッチしていたために SQLiteException が表示されました。ファイル?
01-28 15:25:51.784 12166-12166/ E/AndroidRuntime: FATAL EXCEPTION: main
Process: , PID: 12166
android.database.sqlite.SQLiteException: no such table: temp (code 1): , while compiling: SELECT empID, name, firstName, lastName, email, mobile, designation, location, extension FROM temp WHERE name LIKE ?
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
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:1318)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1165)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1036)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1204)
at com.thbs.database.EmployeeDbAdapter.search(EmployeeDbAdapter.java:194)
at com.thbs.activity.SearchActivity$3.onTextChanged(SearchActivity.java:306)
at android.widget.TextView.sendOnTextChanged(TextView.java:8187)
at android.widget.TextView.handleTextChanged(TextView.java:8249)
at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10371)
at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1208)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:578)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:509)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:508)
at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:844)
at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:198)
at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:353)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:93)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
アプリケーションから開くと正常に動作します
アプリのショートカットを作成するための私のコードは
if (Build.VERSION.SDK_INT >= 25) {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
ShortcutInfo leaveShortcut = new ShortcutInfo.Builder(this, "shortcut_leave")
.setShortLabel("Leave Manager")
.setLongLabel("Leave Manager")
.setIcon(Icon.createWithResource(this, R.drawable.app_icon))
.setIntents(
new Intent[]{
new Intent(Intent.ACTION_MAIN, Uri.EMPTY, this, LeaveManagerActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK),
})
.build();
ShortcutInfo searchShortcut = new ShortcutInfo.Builder(this, "shortcut_search")
.setShortLabel("Employee search")
.setLongLabel("Employee search")
.setIcon(Icon.createWithResource(this, R.drawable.app_icon))
.setIntents(
new Intent[]{
new Intent(Intent.ACTION_MAIN, Uri.EMPTY, this, SearchActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK),
})
.build();
shortcutManager.setDynamicShortcuts(Arrays.asList(leaveShortcut, searchShortcut));
}