runtimeexception

How to throw RuntimeException (“cannot find symbol”)

廉价感情. 提交于 2019-12-03 09:24:19
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 ... throw RuntimeException(msg); 1 error Do I need to import something? Am I misspelling it? I'm sure I must be doing something dumb :-( j flemm throw new RuntimeException(msg); You need the new in there. It's creating an instance and throwing it, not calling a method. jjnguy An Exception is an Object like any other in Java. You need to use the new keyword to

Android RuntimeException onCreateDialog did not create a dialog for id

旧城冷巷雨未停 提交于 2019-12-03 07:36:14
I've an application that you can show and close several Dialogs with: showDialog(...) removeDialog(...) I play a little bit with the application and when there is no any Dialog on the screen, I press the menu button and I go to the main android screen. After a while, I enter again into my application and sometimes, I get this RuntimeException: java.lang.IllegalArgumentException: Activity#onCreateDialog did not create a dialog for id 4 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621) at

Set a menu item as checked from code

巧了我就是萌 提交于 2019-12-03 05:54:55
问题 I have an Android application with the following menu item in one of the Activities (which concerns handling a list of names and mac numbers): <item android:id="@+id/menu_sort_tagg" android:icon="@android:drawable/ic_menu_sort_by_size" android:title="@string/menu_sort_list" > <menu> <group android:checkableBehavior="single"> <item android:id="@+id/sort_by_name" android:title="@string/sort_by_name" /> <item android:id="@+id/sort_by_mac" android:title="@string/sort_by_mac" /> </menu> </item>

“RuntimeException: Performing pause of activity that is not resumed”

僤鯓⒐⒋嵵緔 提交于 2019-12-03 05:42:01
问题 (I see a similar question on stackoverflow, but the answer there is not a true answer, and the context of the problem is a bit different too.) "java.lang.RuntimeException: Performing pause of activity that is not resumed" I develop a game application (which uses both normal Views and GLSurfaceView). If I turn on and off my phone display very fast, I can cause this exception sometimes (thrown by ActivityThread ), but my application is running normally after the exception. My app is a landscape

getActivity() call causes RuntimeException: Could not launch intent Intent act=android.intent.action.MAIN

喜夏-厌秋 提交于 2019-12-03 05:41:23
Updated #1: more info added to the end of this post I'm new to Android development and testing. I have three Espresso tests. First test passes, but the second one will not run because the call to getActivity() in setUp() method before the second test always fails: Blockquote java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=my.packagename/.ActivityMain } within 45 seconds. ... The third test passes. I don't have any long running operations, animations or network calls on creation. I can click through all menu items in my app manually

RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

一曲冷凌霜 提交于 2019-12-02 18:07:40
问题 I've got a code with an ASyncTask and the problem is that when I execute it several times it crashes with this exception: RuntimeException: Only one Looper may be created per thread But then I've read this: https://stackoverflow.com/a/7781280/869180 and I remembered that I had a similar error in the past and it was related to the UI stuff (a ProgressDialog in my case) created in the ASyncTask. So I took off all the UI stuff from the ASyncTask and I removed Looper.prepare too, to avoid that

RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

£可爱£侵袭症+ 提交于 2019-12-02 11:28:18
I've got a code with an ASyncTask and the problem is that when I execute it several times it crashes with this exception: RuntimeException: Only one Looper may be created per thread But then I've read this: https://stackoverflow.com/a/7781280/869180 and I remembered that I had a similar error in the past and it was related to the UI stuff (a ProgressDialog in my case) created in the ASyncTask. So I took off all the UI stuff from the ASyncTask and I removed Looper.prepare too, to avoid that RuntimeException, but know I'm getting this: 12-21 00:34:17.363: W/System.err(18658): java.lang

Android Runtime and Nullpoint Exceptions

感情迁移 提交于 2019-12-02 06:05:44
I have Parse initialization in a class named (ParseInitialization.java) that extends Application and while running my application (MainActivity.java) I got a RuntimeException and whene I call Parse.initialize inside onCreate in (MainActivity.java) I got a NullpointException here is my code: MainActivity.java package com.example.baharat2; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.view.Menu; import android.view.MenuInflater; import com.parse

Single line Lambda and Run-time exceptions - Not compiling?

大憨熊 提交于 2019-12-02 03:25:49
问题 I am working on single line lambda and run time exceptions. I have tested following use cases and found statement 1 is not compiling where as statement 2 is compiling fine. new Thread(() -> throw new RuntimeException("test")); // 1 new Thread(() -> new RuntimeException("test")); //2 Please help me understand why statement 1 is not compiling but statement two is compiling fine. 回答1: A lambda expression is defined (in JLS 15.27. Lambda Expressions ) as: LambdaExpression : LambdaParameters ->

Single line Lambda and Run-time exceptions - Not compiling?

故事扮演 提交于 2019-12-02 00:56:50
I am working on single line lambda and run time exceptions. I have tested following use cases and found statement 1 is not compiling where as statement 2 is compiling fine. new Thread(() -> throw new RuntimeException("test")); // 1 new Thread(() -> new RuntimeException("test")); //2 Please help me understand why statement 1 is not compiling but statement two is compiling fine. A lambda expression is defined (in JLS 15.27. Lambda Expressions ) as: LambdaExpression : LambdaParameters -> LambdaBody A LambdaBody is defined as: LambdaBody : Expression Block In both your lambda expressions, you don