Tag: java

List iterator causes heap allocations?

I’m profiling my android game and surprised to see that: for(O o : myArrayList) { } Creates a bunch of heap allocations. Aside from using a numeric i++ for loop, is there a better way to get around this problem? Can I preallocate my iterators or something?

Is it possible to override a native method in a Java class in Android/dalvik?

I am unit testing a class TestMe using EasyMock, and one of its methods (say method(N n)) expects a parameter of type N which has a native method (say nativeMethod()). class TestMe { void method(N n) { // Do stuff n.nativeMethod(); // Do more stuff } } method() needs to invoke N.nativeMethod() at some point, […]

Aviary crashes on Android L (5.0)

Was just testing my app and found out that after I upgraded my Nexus 5 to Lollipop/5.0, the Aviary SDK I use in it crashes big time. In a google search I found an SO question asked yesterday with the exact same problem, but that question has been deleted by the user (I was able […]

Intercepting clicks from subview in Android

My application has a custom view which contains other custom views of a different type. The subviews have their own click listeners (which I can’t change, as these are in 3rd party libraries). How can I intercept a user’s click at the level of my view to do some processing, and then pass the click […]

android project has red x but no errors in code

I am trying to run android project. The project has a red x on the project folder but none of the sub folder has that red x. No code is highlighted that shows an error. Unfortunately none of my projects are executing. When I run as project it says this error. It does not show […]

android internals and memory/processor constraints?

I’m considering creating a screen reader for Android. My questions are as follows. One how much of the internals of Android are exposed through the Java API? I’m looking for things such as system wide notification when text is displayed, notification of a new application being launched, etc. I’d rather not have to modify the […]

Sending base64 encoded image to server using HttpUrlConnection Android

I’m trying to send base64 encoded images to a server using HttpUrlConnection. The problem I’m having is that most images gets sent successfully, however some generate a FileNotFound exception. My code for encoding the image can be found below. public static String encodeImage(Bitmap thumbnail) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] b […]

Where will code stop running when app is killed from task manager on Android

If a user is running my app and decides to kill it via the task manager, are there any guarantees about how much code will be executed before the process dies? I feel like it could stop running at any arbitrary line, however I guess I don’t really know the answer to this. An example […]

Android app uninstallation event for analytics

I wonder what are the ways/patterns to detect app uninstallation for any kind of analytics on android? I know the limitations of ACTION_PACKAGE_REMOVED intent – not received by application being removed. I am using flurry at the moment and have also discovered that they do not provide any kind of support for deinstallation events. This […]

When caching images and data should you use Internal or External Storage?

I’ve read this Android save app settings/data in Internal/External Storage but I don’t think i’ve really got an answer. I’m developing an app where I should store some “cache” data, like a dozen of images and some strings (json). Initially I was storing all that on the sdcard, (external storage) but later i thought that […]

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