I am modifying the source code here: http://thinkandroid.w开发者_运维问答ordpress.com/2009/12/30/getting-response-body-of-httpresponse/
I get this error: non-static method getContentCharSet(org.apache.http.HttpEntity) cannot be referenced from a static context String charset = getContentCharSet(entity);
This error is line 13 on the second box.
Any ideas? I have been really struggling with this code :-(
You cannot call a non-static function without creating an instance of it. Try not to get in the habit of converting everything to static, but instead just create an instance of the class, and then call the method.
you' are in a static method and you try to call a instance method. but for calling a instance method you have to use a object to call it. you can't just call a instance method without an object.
as already mentioned you could make the other method also static but if this is inappropriate you have to use an instance of the object in which this method is defined to make that call.
Yes, either make all the methods static or not, if they call each other.
In general you would instanciate the class, then call the method on that instance.
In this case, it looks like the missing static is indeed just a typo.
set getContentCharSet(org.apache.http.HttpEntity) to "static" ;-)
精彩评论