Tag: java

Webview with JavaScript interface

I am building a mobile application which should be interacted from java to javascript. I found the solution in this link Passing an array of values from Android Activity to JavaScript in a WebView. But my problem is when i declare webview its showing error like None of the methods in the added interface have […]

SimpleDateFormat: unparseable date exception

After looking after several existing posts, I am still not able to get my SimpleDateFormat parser working. Here is the code: SimpleDateFormat df = new SimpleDateFormat( “EEE, dd MMM yyyy HH:mm:ss Z”, Locale.US); try { volcanoListDate = df.parse(currentValue); } catch (ParseException e) { Log.d(“DEBUG”, e.toString()); Log.d(“DEBUG”, currentValue); } I always end up with a ParseException. […]

Encoding and decoding byte with ZXing

I am developping an Android app, and I need to encode and decode a bytes array in a QRCode generated with the ZXing app. My problem is that my message decoded does not exactly match the generated byte array. I tried to create a QRCode based on a byte array containing incrementing indexes, i.e. input […]

CoordinatorLayout crashes app with IndexOutOfBoundsException

I’m getting a crash (from Crashlytics, unable to reproduce locally) in my app from the onLayout function in the CoordinatorLayout: Fatal Exception: java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at android.support.design.widget.CoordinatorLayout.onLayout(SourceFile:848) at android.view.View.layout(View.java:15237) at android.view.ViewGroup.layout(ViewGroup.java:4864) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515) at android.widget.FrameLayout.onLayout(FrameLayout.java:450) at android.view.View.layout(View.java:15237) at android.view.ViewGroup.layout(ViewGroup.java:4864) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742) at android.widget.LinearLayout.onLayout(LinearLayout.java:1651) at android.view.View.layout(View.java:15237) […]

Android Studio AndroidManifest.xml vs build.gradle

If anyone could help me understand some things regarding Android Studio, it would be most enlightening. So, I have switched from Eclipse to Android Studio around a month ago and so far have only been working on my migrated Apps. As such, I have been tinkering around with only the AndroidManifest.xml file as was customary […]

How to increase console output at the android Log class

For default Log on android platform has limited amount of character for console output. Around equal a bit more than 3000. Therefore, if the message is longer than 3000 characters, it is not shown on screen. I have not found a better solution than this: public class Log { private static int mode = android.util.Log.INFO; […]

Read/write to NFC tag with password protection

I need to write/read textual data to an NFC tag. The way I am expecting the read/write should work is the following: First time write I should be able to set password. Next time when anyone tries to read OR write, if he has the password then he should be able to do the read/write. […]

Android (Java) HttpURLConnection silent retry on 'read' timeout

So I’m using Google Volley for HTTP request, which basically uses Java‘s HttpURLConnection. According to my tests, the problem is this: When the ‘read’ timeout on the HttpURLConnection reaches, a silent retry is executed before the connection is closed and the relevant exception thrown (SocketTimeoutException). Note that: – I noticed this error when using HTTP […]

what to return in onStartCommand for a service

I have been looking through the documentation and sometimes the onStartCommand returns START_NOT_STICKY, sometimes it returns the following: @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub return super.onStartCommand(intent, flags, startId); } I am now confused as to why some services return vs. super.onStartCommand(intent, flags, startId);

How to convert 16-bit PCM audio byte-array to double or float array?

I’m trying to perform Fast Fourier Transform on a .3gpp audio file. The file contains a small 5 second recording in 44100kHz from the phones microphone. Every Java FFT algorithm I can find only takes double[], float[] or Complex[] inputs, for obvious reasons, but I’m reading in the audio file in a byte-array, so I’m […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.