In the app I’m developing on Android, I keep getting a Fatal Signal 11 error. I think it’s something to do with the way that I’m accessing the memory but I can’t figure out what is causing it. Here’s the LogCat: Answer I had been trying to call an uninitialised Canvas inside anot…
Tag: java
Draw a scaled Bitmap to the Canvas?
The following code defines my Bitmap: … And the following code is used to execute/draw it (the unscaled Bitmap): My question is, how might I set it to draw the scaled Bitmap returned in the form of Bitmap scaled, and not the original? Answer Define a new class member variable: Bitmap mScaledBackground; …
Passing a parameter versus returning it from function
As it might be clear from the title which approach should we prefer? Intention is to pass a few method parameters and get something as output. We can pass another parameter and method will update it and method need not to return anything now, method will just update output variable and it will be reflected to…
3-Dimension List or Map
I need something like a 3-dimension (like a list or a map), which I fill with 2 Strings and an Integer within a loop. But, unfortunately I don’t know which data structure to use and how. Answer Create an object that encapsulates the three together and add them to an array or List: If you want to insert …
Spring “The prefix “tx” for element “tx:annotation-driven” is not bound.”
I’m getting the error above on my “tx:annotation-driven” line, but I’ve declared the namespace at the top of the beans file, why is the following XML causing this error? Answer Just like your other xmlns: definations, you need one for xmlns:tx
What is the primary key of an audit table managed by Hibernate Envers?
I am using Hibernate Envers to audit some entities. I manually created the associated audit tables. However, I am having trouble determining what an audit table’s primary key should be. For example, consider a fictional table designed to store customers: And you create the audit table: Here were the opt…
How can I get the package name of the current launcher in android 2.3 and above?
How can I get the package name of the current launcher in android 2.3 and above programmatically in Java ? Answer I think you should be able to use PackageManager.resolveActivity(), with the home intent.
java import “cannot find symbol”
I’m about porting a linux tool to windows. The tool works fine on linux system, but now on windows I get this “cannot find symbol” error. I have this little main class: and the error appears now, while doing javac Main.java: import foo.bar: cannot find symbol ^ symbol: class bar location: pa…
javax.management.AttributeNotFoundException
I am at Camel 2.9.0. I am able to view the MBean data(routes, processors, etc) for running processes in JConsole. I need to display the same in our user interface. While I try to fetch the attribute values, I get the following error. Note – Attribute “EndpointUri” is fetching the right value…
How to use null in switch
In the code above I can’t use null in the switch case statement. How can I do this differently? I can’t use default because then I want to do something else. Answer This is was not possible with a switch statement in Java until Java 18. You had to check for null before the switch. But now, with pa…