Skip to content

Tag: android

What’s the console.log() of java?

I’m working on building an Android app and I’m wondering what the best approach is to debugging like that of console.log in javascript Answer The Log class: API for sending log output. Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods. The order in terms of verbosity, from lea…

How to safely save a file to disk in android?

I have written an android app that saves (potentially) large files to the SD Card. Occasionally I get an IOException during the write operation which causes the file to be left in a corrupt state. Based on the answer to this question: Question: How to safely write to a file? the strategy I should use is to cr…

Unparseable date exception in java

These lines of codes causees this exception what is the possible solution ? Answer Your format is completely wrong. Not only are you using mm (which means minutes) when you probably meant MM, but this: is clearly not in the format You probably want something like EDIT: That works for me in desktop Java: You m…

How to connect via HTTPS using Jsoup?

It’s working fine over HTTP, but when I try and use an HTTPS source it throws the following exception: Here’s the relevant code: Answer If you want to do it the right way, and/or you need to deal with only one site, then you basically need to grab the SSL certificate of the website in question and…

How to get frequency from fft result?

I have recorded an array[1024] of data from my mic on my Android phone, passed it through a 1D forward DFT of the real data (setting a further 1024 bits to 0). I saved the array to a text file, and repeated this 8 times. I got back 16384 results. I opened the text file in Excel and made a

How to get the JAR file for sun.misc.BASE64Encoder class?

I have some code in my Activity class that uses sun.misc.BASE64Encoder class. But it is showing java.lang.NoClassDefFoundError : sun.misc.BASE64Encoder. Do I need the jar? Where can I download it from? Answer Don’t use sun.* classes. For Base64 in Android, use its native class or add a library to your p…