How can I console.log functions alongside all their properties?

I’m using the Google Chrome console. Frustratingly, the following code

var f = function () {};
f.a = 1;

will only log

function () {}

Why does it not print the properties of f, such as f.a and f.prototype? How can I print them?


Try console.dir.


Better options than backporting ICS HttpResponseCache

I need to cache http responses, and based on this blog post that functionality is built into ICS. However, I need to support versions 1.6 and up so wanted to see if there are ready to use libraries out there before looking at what’s need to backport the ICS functionality.


Here’s the link to HttpResponseCache which only supports

Second update:

After some research, it looks like Apache’s HttpClient does support caching, with the caveat that the default (in-memory) backend is probably not a good idea for memory-constrained Android apps. Ehcache may be a good option depending on its support for Android.


I created this issue requesting that a renamed, backwards compatible version of be added to the compatibility library:

Google declined the issue, but offered to help me in making the backport and library. So I’m trying to do that.

Also, HttpClient-Cache may be a neat thing to use. It doesn’t work on Android as is, you need to make a small modification and recompile it. See

However, I’d recommend you try – it’s a repackaged (renamed) version of HttpClient and HttpClient-Cache for Android. It’s quite simple to set up (just include a jar and then use ch.boye.httpclientandroidlib.* instead of org.apache.http.*).


NoSuchMethod with addAll in Adapter?

I have a subclass of an ArrayAdapter declared like this

public class ShoppingCartAdapter extends ArrayAdapter<ShoppingCart> {

and everything has been working fine. Now suddenly(?) I have problems with this on my Nexus S running 2.3.6 or an emulator with 2.2 throwing

12-19 14:33:36.136: ERROR/AndroidRuntime(27326): FATAL EXCEPTION: main

however it still works just fine on e.g. my Xoom with 3.2.

I am not overriding the super addAll methods and since it works on some device I am not sure where to look next. Any hints?


I replaced adapter.addAll(newCarts) with

for (ShoppingCart cart : newCarts) {

and that works. I assume it has something to do with generics but have been unable to nail it down yet.



has been added starting from API 11 (Android 3.0). Here the doc.


Uncaught ReferenceError:foobar is not defined (anonymous function)

I have this js file serving from some domain say


$(document).ready(function() {
        function foobar(bar){
                    url: "/site/foo/",
                data: {'foo':bar},
                    dataType: "jsonp",
                    crossdomain: !0,
                    success: function (data) {
                    error: function () {

On on some url, I have something like this:

<script src='' type='text/javascript'></script>
<script type='text/javascript'>foobar('123456')</script>

When I hit that url : it says

Uncaught ReferenceError:foobar is not defined (anonymous function)

How to access function from other domains?


You’ve defined “foobar()” inside the “ready” handler. It’s therefore a local variable in that function, and invisible outside it.

You could add this to the end of the “ready” handler:

  window['foobar'] = foobar;

and then it’d be visible globally.

By the way this is something that can bite at jsfiddle because it (by default) will wrap code in a “load” handler. Thus, if you copy/paste from a JavaScript file included in the <head>, a function that would be global in that context ends up not global in the fiddle.


Can same facebook app id be used for both android and iphone app?

I have two apps which have same name and same functions. One in android market and one in app store. Currently only with iphone app you can post your score on your facebook wall using the facebook app i created. My question is can i use same app for android also to post the score on user’s wall? Will it create any problems if i do that?


Yes, you can use the same application ID. You should, in fact, as it’ll prevent you from having analytics and user permissions split between the two.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..