I have detected some of my activities are blocked at the launch. So I wrote that code in a new project: And the result is that the first creation of an AdView object blocks the UI thread for between 1 and 2 seconds. Is there some way of avoiding that? Thanks Answer You are creating your AdView in your UI
Tag: java
Why is this ArrayList throwing a ConcurrentModificationException when I try to remove an element?
I’m trying to remove a particular element from Arraylist, it throws an ConcurrentModificationException any comments, what am I doing wrong? Answer Only remove an element from the array while iterating by using Iterator.remove(). The line for(String st: ar) { is a bit misleading. You’re actually cr…
How to change spaces to underscore and make string case insensitive?
I have following question. In my app there is a listview. I get itemname from listview and transfer it to the webview as a string. How to ignore case of this string and change spaces to underscores? For example: String itemname = “First Topic”. I transfer it to the next activity and want to ignore…
Background process in linux
I have developed a Java socket server connection which is working fine. When started from a terminal, it starts from listening from client. But when I close the terminal it stops listening. I need to continue even though the terminal closed by user from where jar file was started. How can I run Java server so…
Can’t compile project when I’m using Lombok under IntelliJ IDEA
I’m trying to use Lombok in my project that I’m developing using IntelliJ IDEA 11. I’ve installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields. So I have a class that uses Slf4j. I annotated it like this But when I build my project co…
jndi LDAPS custom HostnameVerifier and TrustManager
We are writing an application that shall connect to different LDAP servers. For each server we may only accept a certain certificate. The hostname in that certificate shall not matter. This is easy, when we use LDAP and STARTTLS, because we can use StartTlsResponse.setHostnameVerifier(..-) and use StartTlsRes…
Unicode text through socket in java
I am facing a tiny issue (I believe) in socket programming. When sending text from non-English languages, I get garbled results. After a lot of researching on google, I made some corrections. I changed getBytes() to getBytes(“UTF-8”) and tried to send some Arabic text. When connecting sockets loca…
Java – Split String into sentences with character limitation
I want to split a text into sentences (split by . or BreakIterator). But: Each sentence mustn’t have more than 100 characters. Example: To: (3 elements, without breaking a word, but a sentence) How can I do this properly? Answer Solved (thank you Macarse for the inspiration):
Viewing MBeans through jstatd
I am trying to monitor all Java processes running on a server via jstatd. I’ve got it set up enough that I can connect with VisualVM and see all running processes. Most displays work fine, however certain things (especially CPU usage and MBeans) do not display. Instead, it says: MBeans Browser Data not …
Platform’s default charset on different platforms?
Some legacy code relies on the platform’s default charset for translations. For Windows and Linux installations in the “western world” I know what that means. But thinking about Russian or Asian platforms I am totally unsure what their platform’s default charset is (just UTF-16?). Ther…