朋友的 我在我的应用程序中实现了带有搜索选项的地图,当我在HTC中运行应用程序时,SonyEricson运行良好,但是当我在Motorola Droid 2.2中进行搜索时,我得到了数字格式异常, 这里是我的搜索选项代码
findViewById(R.id.map_search).setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
try{
onSearchRequested();
}
catch(Exception e)
{
Log.v("Error",""+e);
}
}
});
这里我从数据库中获取数据以搜索列表数据给用户。 这是我的数据库端代码
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String orderBy) {
if (uriMatcher.match(uri) == BRUMAPS_ID) {
long id = Long.parseLong(uri.getPathSegments().get(1));
selection = appendRowId(selection, id);
}
if (uriMatcher.match(uri) == BRUMAPS) {
db = news.getReadableDatabase();
cursor = db.query(TABLE_NAME2, projection, selection,
selectionArgs, null, null, orderBy);
}
}
低于我在Moto-Droid 2.2中获得的异常即使在Droid 2.1中也能正常运行
10-22 14:14:20.832: DEBUG/ThrottleService(60): onPollAlarm - roaming =false, read =0, written =0, new total =0
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): error changing cursor and caching columns
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): java.lang.NumberFormatException:
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at java.lang.Long.parseLong(Long.java:347)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at java.lang.Long.parseLong(Long.java:320)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.database.MatrixCursor.getLong(MatrixCursor.java:255)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.database.CursorWrapper.getLong(CursorWrapper.java:127)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.CursorAdapter.getItemId(CursorAdapter.java:156)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.AutoCompleteTextView.buildDropDown(AutoCompleteTextView.java:1248)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1137)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:1019)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:1002)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.app.SearchDialog.onDataSetChanged(SearchDialog.java:612)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.app.SuggestionsAdapter.notifyDataSetChanged(SuggestionsAdapter.java:193)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.CursorAdapter.changeCursor(CursorAdapter.java:260)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.app.SuggestionsAdapter.changeCursor(SuggestionsAdapter.java:238)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.CursorFilter.publishResults(CursorFilter.java:67)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.os.Looper.loop(Looper.java:123)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at java.lang.reflect.Method.invoke(Method.java:521)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-22 14:14:21.442: ERROR/SuggestionsAdapter(319): at dalvik.system.NativeStart.main(Native Method)
10-22 14:14:21.493: DEBUG/AndroidRuntime(319): Shutting down VM
10-22 14:14:21.493: WARN/dalvikvm(319): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): FATAL EXCEPTION: main
10-22 14:14:21.522: ERROR/AndroidRuntime(319): java.lang.NumberFormatException:
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at java.lang.Long.parseLong(Long.java:347)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at java.lang.Long.parseLong(Long.java:320)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.database.MatrixCursor.getLong(MatrixCursor.java:255)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.database.CursorWrapper.getLong(CursorWrapper.java:127)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.widget.CursorAdapter.getItemId(CursorAdapter.java:156)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.widget.AutoCompleteTextView.buildDropDown(AutoCompleteTextView.java:1248)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1137)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:1019)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:1002)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.os.Looper.loop(Looper.java:123)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at java.lang.reflect.Method.invoke(Method.java:521)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-22 14:14:21.522: ERROR/AndroidRuntime(319): at dalvik.system.NativeStart.main(Native Method)
10-22 14:14:21.563: WARN/ActivityManager(60): Force finishing activity com.example.brown/.Bru_Maps
10-22 14:14:22.172: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{44eed238 com.example.brown/.Bru_Maps}
10-22 14:14:23.671: WARN/InputConnectionWrapper.ICC(108): Timed out waiting on IInputContextCallback
10-22 14:14:25.813: WARN/InputConnectionWrapper.ICC(108): Timed out waiting on IInputContextCallback
10-22 14:14:26.451: DEBUG/dalvikvm(108): GC_EXTERNAL_ALLOC freed 2450 objects / 141280 bytes in 320ms
单独在Droid2.2中解决此问题的原因是什么,但它可以解决其他设备问题。我可以解决这个问题。
提前致谢