Tag: exception-handling

Avoid try/catch on Android

I am new in Android environment and I have started writing some code to execute some queries on a database. When I have to handle exceptions I don’t know what the appropriate way is to do it – out of Android I used to use throws declaration on methods but it seems that throws isn’t […]

MonoDroid: Unhandled Exception Recovery

I’m trying to add a default handler to my application so I can recover from otherwise unhandled exceptions. I’ve found three mechanisms provided by Android/MonoDroid that, as far as I can tell, should make this possible, but I cannot get any of them to work. Here’s my code: using System; using Android.App; using Android.Content; using […]

Global Exception Handlers in Java

I am thinking of setting up a global, default Exception handler for my (Android) Mobile application(which uses Java syntax) using Thread.setDefaultUncaughtExceptionHandler(…) call. I am thinking of just displaying an Alert Dialog with appropriate message to the user. Are there any gotchas, caveats and rules that one needs to follow when setting DefaultExceptionHandlers? Any best practices […]

Android: handle unexpected internet disconnect while downloading data

I have here a function that downloads data from a remote server to file. I am still not confident with my code. My question is, what if while reading the stream and saving the data to a file and suddenly I was disconnected in the internet, will these catch exceptions below can really catch that […]

install Exception device not found ANDROID

After increasing the timeout period trying kill server and start server commands restarting avd recreating avd restarting the application restarting the system I’m still getting : Failed to install DataAttach.apk on device ’emulator-5554′: device not found com.android.ddmlib.InstallException: device not found Launch canceled! What can be done in this case? I’m running this app on Emulator […]

Where can I get a JAR to import libcore.io?

I want to handle an GaiException in my App. The debugger tells me, it lives in the libcore.io package, but importing it yields an error. I guess I need to add an additional JAR to my projct to correctly resolve this type. I’ve been digging a bit in my android sdk folder, but don’t seem […]

SQLiteConstraintException not caught

What is the problem with this code? It doesn’t catch the exception thrown by insertChild() method. childDbOps.open(); try { childDbOps.insertChild(child); } catch (SQLiteException exception) { Log.i(“error la inserare child”, “on the next line”); exception.printStackTrace(); } finally { childDbOps.close(); } The error is: ERROR/Database(320): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed at com.android.dataLayer.DbAdapter.insertChild(DbAdapter.java:169) at com.android.activities.ChildInsertActivity.onClick(ChildInsertActivity.java:203) at android.view.View.performClick(View.java:2344) […]

Exception is NULL always

Can someone explain to me why the Android “Catch” handler will not initialize an Exception object? When an error occurs and my code is trying to initialize an Exception object it is ALWAYS NULL. The above doesn’t make sense to me because the exception should always initialize the Exception object period. It should never be […]

Android : avoid crashing of app due to unhandled errors

In my Android app I have tried to put Try Catch blocks in all possible places. However I want to avoid the crashing of the app due to any unhandled errors. How can I achieve that? I have used Thread.setDefaultUncaughtExceptionHandler(handler); but that will just help me to obtain crash- data right?

Exception stack trace lost in Google Analytics v2 for Android?

The stack trace is crucial to fix problems. In Android you can find nice reports in the Play store console. Unless you use Google Analytics V2. In this case Analytics seems to swallow the exceptions. Worse, Analytics seems to log only the first line of the exception and thus loosing the stacktrace. At least it […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.