java.lang.RuntimeException: Handler (android.os.Handler) sending message to a Handler on a dead thread

The problem here is that you are creating a Toast inside a thread that is managed by the IntentService. The system will use the Handler associated with this thread to show and hide the Toast. First the Toast will be shown correctly, but when the system tries to hide it, after the onHandleIntent method has … Read more

“RuntimeException: native typeface cannot be made” when loading font

Android does not support OpenType (OTF), only TrueType (TTF), so your Molot.otf font probably will not work. I wrote both of those blog posts you link to in your opening sentence (the one is a pirated copy of the other), and they do not use Molot.otf. (BTW, I somewhat repaired the formatting of that post … Read more

How to explain whether Exception will catch RuntimeException?

The premise of the question is flawed, because catching Exception does catch RuntimeException. Demo code: public class Test { public static void main(String[] args) { try { throw new RuntimeException(“Bang”); } catch (Exception e) { System.out.println(“I caught: ” + e); } } } Output: I caught: java.lang.RuntimeException: Bang Your loop will have problems if: callbacks … Read more

Can’t create handler inside thread which has not called Looper.prepare()

The error is self-explanatory… doInBackground() runs on a background thread which, since it is not intended to loop, is not connected to a Looper. You most likely don’t want to directly instantiate a Handler at all… whatever data your doInBackground() implementation returns will be passed to onPostExecute() which runs on the UI thread. mActivity = … Read more

Unable instantiate android.gms.maps.MapFragment

In IntelliJ IDEA (updated for IntelliJ 12): Create a file ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/src/dummy.java containing class dummy {}. File->Import Module-> ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib Create Module from Existing Sources Next->Next->Next->Next->Finish File->Project Structure->Modules->YourApp +->Module Dependency->Google-play-services_lib (The + button is in the top right corner of the dialog.) +->Jars or directories->~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar Use the up/down arrows to move <Module source> to the bottom of … Read more

Error: Registry key ‘Software\JavaSoft\Java Runtime Environment’\CurrentVersion’? [duplicate]

On my Windows 7 machine, it was solved by doing the following: In the START menu type “regedit” to open the Registry (be careful doing this) Go to “HKEY_LOCAL_MACHINE” on the left-hand side registry explorer/tree menu Click “SOFTWARE” within the “HKEY_LOCAL_MACHINE” registries Click “JavaSoft” within the “SOFTWARE” registries Click “Java Runtime Environment” within the “JavaSoft” … Read more

ActionBarCompat: java.lang.IllegalStateException: You need to use a Theme.AppCompat

If you are extending ActionBarActivity in your MainActivity, you will have to change the parent theme in values-v11 also. So the style.xml in values-v11 will be – <!– res/values-v11/themes.xml –> <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”QueryTheme” parent=”@style/Theme.AppCompat”> <!– Any customizations for your app running on devices with Theme.Holo here –> </style> </resources> EDIT: I would … Read more

Android 1.6: “android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application”

Instead of : Context appContext = this.getApplicationContext(); you should use a pointer to the activity you’re in (probably this). I got bitten by this today too, the annoying part is the getApplicationContext() is verbatim from developer.android.com 🙁