Questions tagged [runtimeexception]

RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Virtual Machine.

RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Virtual Machine.

1062 questions
757
votes
21 answers

Understanding checked vs unchecked exceptions in Java

Joshua Bloch in "Effective Java" said that Use checked exceptions for recoverable conditions and runtime exceptions for programming errors (Item 58 in 2nd edition) Let's see if I understand this correctly. Here is my understanding of a…
391
votes
6 answers

NameError: global name 'xrange' is not defined in Python 3

I am getting an error when running a python program: Traceback (most recent call last): File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 110, in File "C:\Program Files (x86)\Wing IDE 101…
Pip
  • 4,387
  • 4
  • 23
  • 31
309
votes
16 answers

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

I'm trying to open a dialog window, but every time I try to open it it throws this exception: Uncaught handler: thread main exiting due to uncaught exception android.view.WindowManager$BadTokenException: Unable to add window -- token null is…
217
votes
11 answers

Calling startActivity() from outside of an Activity?

I'm using an AlarmManager to trigger an intent that broadcasts a signal. The following is my code: AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(this, Wakeup.class); try { PendingIntent pi =…
Tom G
  • 2,595
  • 5
  • 20
  • 16
134
votes
12 answers

Android 'Unable to add window -- token null is not for an application' exception

I get the following Android exception when I try to open a dialog. Can someone please help me understand what is going on and how can I fix this problem? android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for…
michael
  • 106,540
  • 116
  • 246
  • 346
102
votes
13 answers

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

I am getting a RuntimeException on Android 2.3.5 but I am using Theme.AppCompat (res/values/themes.xml). This is the phone: http://www.gsmarena.com/samsung_galaxy_y_s5360-4117.php
AG1
  • 6,648
  • 8
  • 40
  • 57
86
votes
14 answers

Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'?

When I run: C:\Users\ashahria\Downloads>java -jar schemaSpy_5.0.0.jar I get the error below. What is wrong? How can I fix it? Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.5', but '1.7' is…
itro
  • 7,006
  • 27
  • 78
  • 121
83
votes
30 answers

Unable instantiate android.gms.maps.MapFragment

I try to do a demo with google maps android v2 with very simple activity, just copy code from google page: https://developers.google.com/maps/documentation/android/start#adding_the_api_key_to_your_application for activity: package…
mmm2006
  • 1,227
  • 2
  • 11
  • 18
82
votes
7 answers

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

I have an Activity, and in that I have a class. text=new Dynamictext(...); text.setText("txt"); in my DynamicText java I have this code: public void setText(String text) { this.text=text; new asyncCreateText().execute(); …
lacas
  • 13,928
  • 30
  • 109
  • 183
74
votes
5 answers

How to explain whether Exception will catch RuntimeException?

This is very odd to me. RuntimeException inherits from Exception, which inherits from Throwable. catch(Exception exc) { /* won't catch RuntimeException */ but catch(Throwable exc) { /* will catch RuntimeException */ I know RuntimeException is…
djechlin
  • 59,258
  • 35
  • 162
  • 290
64
votes
9 answers

"RuntimeException: native typeface cannot be made" when loading font

I am attempting to use a custom font for a TextView on Android, following the guide here. Using the same font, same code, same everything, I get this in adb logcat: W/dalvikvm( 317): threadid=1: thread exiting with uncaught exception…
TheLQ
  • 14,830
  • 14
  • 69
  • 107
61
votes
3 answers

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

in my app I'm using IntentService for sending SMS. @Override protected void onHandleIntent(Intent intent) { Bundle data = intent.getExtras(); String[] recipients = null; String message = getString(R.string.unknown_event); String…
eyal
  • 2,379
  • 7
  • 40
  • 54
49
votes
5 answers

How to properly catch RuntimeExceptions from Executors?

Say that I have the following code: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(myRunnable); Now, if myRunnable throws a RuntimeExcpetion, how can I catch it? One way would be to supply my own ThreadFactory…
Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
46
votes
9 answers

How to throw RuntimeException ("cannot find symbol")

I'm trying to throw an exception in my code like this: throw RuntimeException(msg); But when I build in NetBeans I get this error: C:\....java:50: cannot find symbol symbol : method RuntimeException(java.lang.String) location: class ... …
Greg
  • 45,306
  • 89
  • 231
  • 297
46
votes
5 answers

java.lang.RuntimeException: takePicture failed

when i do continuous click on Capture button (without any break), getting Runtime Exception how can i resolve this issue ? if its not possible so how may i handle this Exception ? btnCapture = (ImageButton) findViewById(R.id.btnCapture); …
Sun
  • 6,768
  • 25
  • 76
  • 131
1
2 3
70 71