Skip to content
Advertisement

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 least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should

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 create a temporary

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 may want to set the

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 import it in

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

Does anyone know how to decode and encode a string in Base64 using Base64?

I am using the following code, but it’s not working. Answer First: Choose an encoding. UTF-8 is generally a good choice; stick to an encoding which will definitely be valid on both sides. It would be rare to use something other than UTF-8 or UTF-16. Transmitting end: Encode the string to bytes (e.g. text.getBytes(encodingName)) Encode the bytes to base64 using

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 project that does this (Apache commons, etc.). Alternatively just copy the

Advertisement