Problems with populating a ListView with SQLite - android

I'm trying to populate my own SQLite db into the android listview for viewing but have a problem, the code runs but will generate an "unexpected quitting".
I've checked my DDMS and the emulator has my SQLite file within the database which was copied from the assets file.
I'm not sure what went wrong here, can anyone can give me some pointers where i should start looking from? Or is there anything even wrong with the code I've provided below ? Any where i can check for potential kinks in the code ?
Thank you !!!
private void fillData() {
Cursor drugsCursor = mDbHelper.fetchAllDrugs();
startManagingCursor(drugsCursor);
//Creating an array to specify the fields we want
String[] from = new String[] {DrugsDbAdapter.KEY_ROWID};
//and an array of the fields we want to bind in the view
int[] to = new int[] {R.id.text1};
//To Create the simple cursor adapter and set it to display
SimpleCursorAdapter drugs = new SimpleCursorAdapter(this, R.layout.drug_row, drugsCursor, from, to);
setListAdapter(drugs);
}
and the DrugsDbAdapter.java handling the Cursor is here
public Cursor fetchAllDrugs() {
return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_DRUG, KEY_CONTENT, KEY_INDICATION, KEY_DOSAGE, KEY_SPECIALPRECAUTION} , null, null, null, null, null);
}
The output of my LogCat (the red color portion of the output- should i be posting the whole log?) is:
05-25 18:12:22.338: WARN/dalvikvm(27763): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): FATAL EXCEPTION: main
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.paad.medboxsd/com.paad.medboxsd.medboxsd}: java.lang.NullPointerException
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.os.Looper.loop(Looper.java:123)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at java.lang.reflect.Method.invoke(Method.java:521)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at dalvik.system.NativeStart.main(Native Method)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): Caused by: java.lang.NullPointerException
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.paad.medboxsd.medboxsd.fillData(medboxsd.java:67)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.paad.medboxsd.medboxsd.onCreate(medboxsd.java:56)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-25 18:12:22.434: ERROR/AndroidRuntime(27763): ... 11 more
05-25 18:12:22.514: WARN/ActivityManager(59): Force finishing activity com.paad.medboxsd/.medboxsd
05-25 18:12:23.034: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450fc298 com.paad.medboxsd/.medboxsd}

I suspect the problem is that you're not providing a column named '_id' to your Cursor. See my answer to Android: column '_id' does not exist problem

Related

Couldn't find libtensorflow_demo.so while importing Tensorflow example on Android

I am importing Tensorflow example to run it in Android 5 simulator on Windows, but I am getting this error. Do you know why that happens?
05-25 17:14:31.340: E/AndroidRuntime(1189): FATAL EXCEPTION: main
05-25 17:14:31.340: E/AndroidRuntime(1189): Process:
org.tensorflow.demo, PID: 1189 05-25 17:14:31.340:
E/AndroidRuntime(1189): java.lang.UnsatisfiedLinkError:
dalvik.system.PathClassLoader[DexPathList[[zip file
"/data/app/org.tensorflow.demo-2/base.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]] couldn't find "libtensorflow_demo.so" 05-25
17:14:31.340: E/AndroidRuntime(1189): at
java.lang.Runtime.loadLibrary(Runtime.java:366) 05-25 17:14:31.340:
E/AndroidRuntime(1189): at
java.lang.System.loadLibrary(System.java:989) 05-25 17:14:31.340:
E/AndroidRuntime(1189): at
org.tensorflow.demo.TensorflowClassifier.(TensorflowClassifier.java:47)
05-25 17:14:31.340: E/AndroidRuntime(1189): at
org.tensorflow.demo.TensorflowImageListener.(TensorflowImageListener.java:55)
05-25 17:14:31.340: E/AndroidRuntime(1189): at
org.tensorflow.demo.CameraConnectionFragment.(CameraConnectionFragment.java:452)
05-25 17:14:31.340: E/AndroidRuntime(1189): at
org.tensorflow.demo.CameraConnectionFragment.newInstance(CameraConnectionFragment.java:271)
05-25 17:14:31.340: E/AndroidRuntime(1189): at
org.tensorflow.demo.CameraActivity.onCreate(CameraActivity.java:33)
05-25 17:14:31.340: E/AndroidRuntime(1189): at
android.app.Activity.performCreate(Activity.java:5937) 05-25
17:14:31.340: E/AndroidRuntime(1189): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
Below my AVD settings --

Genymotion Crash after a few minutes

I have built a demo application which works perfectly, and looks like the following:
Then after a few runs, Genymotion suddenly stops working, and a screen like the following appears:
.
The Logcat keeps recording the following lines:
05-25 13:58:24.326: E/eglCodecCommon(2163): writeFully: failed: Broken pipe
05-25 13:58:24.418: E/EGL_genymotion(2163): tid 2163: eglChooseConfig(544): error 0x3001 (EGL_NOT_INITIALIZED)
05-25 13:58:24.422: E/AndroidRuntime(2163): FATAL EXCEPTION: main
05-25 13:58:24.422: E/AndroidRuntime(2163): Process: com.nextgenintl.aimassistant, PID: 2163
05-25 13:58:24.422: E/AndroidRuntime(2163): java.lang.IllegalArgumentException: eglChooseConfig failed EGL_NOT_INITIALIZED
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.HardwareRenderer$GlRenderer.chooseEglConfig(HardwareRenderer.java:1173)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.HardwareRenderer$GlRenderer.loadEglConfig(HardwareRenderer.java:1135)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.HardwareRenderer$GlRenderer.initializeEgl(HardwareRenderer.java:1117)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:1057)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1550)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.Choreographer.doFrame(Choreographer.java:544)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.os.Handler.handleCallback(Handler.java:733)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.os.Handler.dispatchMessage(Handler.java:95)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.os.Looper.loop(Looper.java:136)
05-25 13:58:24.422: E/AndroidRuntime(2163): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-25 13:58:24.422: E/AndroidRuntime(2163): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 13:58:24.422: E/AndroidRuntime(2163): at java.lang.reflect.Method.invoke(Method.java:515)
05-25 13:58:24.422: E/AndroidRuntime(2163): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-25 13:58:24.422: E/AndroidRuntime(2163): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-25 13:58:24.422: E/AndroidRuntime(2163): at dalvik.system.NativeStart.main(Native Method)
If I shut down Genymotion and relaunch it, it works fine again.
What is the cause of this problem, and is anyone experiencing it too?
It's not really caused by your application, so don't worry.
It often happens when you computer goes in sleep mode and when you come back Genymotion will throw this exception (it happens to me very often).
In your specific case sounds like the device goes in sleep mode so a way to fix it is simply to enable "Always stay awake" in developers options.
Another way to fix it is just to turn off your emulator and relaunch. (as you already do)
The broken pipe error means there is a problem with the connection between emulator and host computer.
To fix it you can restart the emulator (or follow the advice from the other answer).
I had the same problem and fixed it choosing the same resolution of my virtual device. It says "Custom Tablet - 6.0.0 - API 23 - 2560x1600" and the resolution was lower than this. When I put the same, the device doesn't crash anymore

Selecting an item in ListFragment list programmatically

I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}

Application Force Close after update sdk

I have updated my android sdk from r21 to r22. I also updated the adt. Before the updates, my application work perfectly without error and force close. But now, all of my apps are force close when run via avd or real phone. I don't know the problem, but, it seems that the compiler didn't found my MainActivity class. I have already checked it many times, and I'm sure that my MainActivity doesn't have any error and compile properly.
Here's the logcat error:
05-25 01:11:02.931: E/AndroidRuntime(7724): FATAL EXCEPTION: main
05-25 01:11:02.931: E/AndroidRuntime(7724): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ca.slim.social/ca.slim.social.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "ca.slim.social.MainActivity" on path: /data/app/ca.slim.social-2.apk
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2223)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.ActivityThread.access$600(ActivityThread.java:153)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.os.Looper.loop(Looper.java:137)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.ActivityThread.main(ActivityThread.java:5224)
05-25 01:11:02.931: E/AndroidRuntime(7724): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 01:11:02.931: E/AndroidRuntime(7724): at java.lang.reflect.Method.invoke(Method.java:511)
05-25 01:11:02.931: E/AndroidRuntime(7724): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
05-25 01:11:02.931: E/AndroidRuntime(7724): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
05-25 01:11:02.931: E/AndroidRuntime(7724): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
05-25 01:11:02.931: E/AndroidRuntime(7724): at dalvik.system.NativeStart.main(Native Method)
[tpb]05-25 01:11:02.931: E/AndroidRuntime(7724): Caused by: java.lang.ClassNotFoundException: Didn't find class "ca.slim.social.MainActivity" on path: /data/app/ca.slim.social-2.apk[/tpb]
05-25 01:11:02.931: E/AndroidRuntime(7724): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-25 01:11:02.931: E/AndroidRuntime(7724): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-25 01:11:02.931: E/AndroidRuntime(7724): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-25 01:11:02.931: E/AndroidRuntime(7724): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2214)
05-25 01:11:02.931: E/AndroidRuntime(7724): ... 12 more
NB: I'm using actionbarsherlock, slidingmenu, and viewpagerindicator.
Thank You
Lots of people are having this issue!
Try these solutions:
ClassNotFoundException after ADT update
Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using. Clean all projects afterwards and see what happens.
Eclipse giving error, missing R.java file after recent update
After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools.
Which version of java you are using? Try to update your JDK to 1.7 and let us know if that helps. You could also try the suggestions in this link to help troubleshoot your problem.

Network in UI thread in an android device(android 3.0 or newer)

I have to parse a website html code and show some info in my app
So I tried JSoup for getting result
It works great on the emulator but in a real device it will crashes; here is the log :
05-25 21:42:20.935: D/AndroidRuntime(32230): Shutting down VM
05-25 21:42:20.935: W/dalvikvm(32230): threadid=1: thread exiting with uncaught exception (group=0x401b9760)
05-25 21:42:20.940: E/AndroidRuntime(32230): FATAL EXCEPTION: main
05-25 21:42:20.940: E/AndroidRuntime(32230): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abbasizadeh.Currency/com.abbasizadeh.Currency.CurrencyUpdatableActivity}: android.os.NetworkOnMainThreadException
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.ActivityThread.access$500(ActivityThread.java:122)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.os.Looper.loop(Looper.java:132)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-25 21:42:20.940: E/AndroidRuntime(32230): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 21:42:20.940: E/AndroidRuntime(32230): at java.lang.reflect.Method.invoke(Method.java:491)
05-25 21:42:20.940: E/AndroidRuntime(32230): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
05-25 21:42:20.940: E/AndroidRuntime(32230): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
05-25 21:42:20.940: E/AndroidRuntime(32230): at dalvik.system.NativeStart.main(Native Method)
05-25 21:42:20.940: E/AndroidRuntime(32230): Caused by: android.os.NetworkOnMainThreadException
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
05-25 21:42:20.940: E/AndroidRuntime(32230): at java.net.InetAddress.lookupHostByName(InetAddress.java:477)
05-25 21:42:20.940: E/AndroidRuntime(32230): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:277)
05-25 21:42:20.940: E/AndroidRuntime(32230): at java.net.InetAddress.getAllByName(InetAddress.java:249)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:69)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:304)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:292)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:274)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:217)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:404)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:391)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:157)
05-25 21:42:20.940: E/AndroidRuntime(32230): at org.jsoup.helper.HttpConnection.get(HttpConnection.java:146)
05-25 21:42:20.940: E/AndroidRuntime(32230): at com.abbasizadeh.Currency.CurrencyUpdater.updateInfo(CurrencyUpdater.java:35)
05-25 21:42:20.940: E/AndroidRuntime(32230): at com.abbasizadeh.Currency.CurrencyUpdatableActivity.onCreate(CurrencyUpdatableActivity.java:20)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
05-25 21:42:20.940: E/AndroidRuntime(32230): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
05-25 21:42:20.940: E/AndroidRuntime(32230): ... 11 more
in CurrencyUpdatableActivity.java:20 I call CurrencyUpdater.java:35 and
CurrencyUpdater.java:35 is this:
Document document = Jsoup.connect(url).get();
thank you for your help in this strange issue
Edit: I added the android version problem to my title for better search for others
In Android 3.0 and newer, you're banned from touching the network or file IO on the UI thread. This is a good thing since it forces you to not interrupt the user interface for operations that may take a long time. Look at this line in your log:
05-25 21:42:20.940: E/AndroidRuntime(32230): Caused by: android.os.NetworkOnMainThreadException
You've already figured out where the exception is thrown, now you need to put that code in the doInBackground() method of an AsyncTask.

Categories

Resources