Android Connect Exception
i get a strange error message when i try to start an url connection. here´s the log output:
E/admarvelservice( 2366): postString: &site_id=14488&partner_id=ef8a30b841b36346& timeout=5000&version=1.5&language=java&format=android&sdk_version=2.1.3&sdk_version_date=2011-08-08&device_model=Nexus+S&device_name=GRJ22&get_cached_ads=true&device_systemversion=2.3.5&resolution_wid开发者_运维问答th=480&max_image_width=480&resolution_height=800&max_image_height=800&device_os=Android&target_params=appv%3D%3ES%7C%7Cla%3D%3Ede%7C%7Cco%3D%3EAT%7C%7Cscreenorient%3D%3Ep%7C%7Cappvn%3D%3E3.4.0%252F%7C%7Cosv%3D%3E2.3.5
D/admarvelservice( 2366): Error: java.net.ConnectException: ads.admarvel.com/127.0.0.1:80 - Connection refused
anybody an idea whats the problem here? thanks.
EDIT: how i connect:
URL myURL;
try {
myURL = new URL(_url);
m_ucon = myURL.openConnection();
m_ucon.setConnectTimeout(8000);
} catch (Exception e) {
e.printStackTrace();
}
funny thing is that the connection is working, but every second my logcat shouts the errormessage shown above.
I think this has nothing to do with your application. The exception comes from an Advertising Service (admarvelservice).
You are using an adblocker app and you have Shazam installed. Just either get the paid version of Shazam, remove ad blocker or just ignore the error.
Check this first in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Localhost ip address is: 127.0.0.1
so u can check by this too.
try with this http connection:
public SomeClass {
HTTTPUrlConnection conn = new HTTPUrlConnection(...);
SomeClass instance = new SomeClass();
private SomeClass() {}
public static getInstance() {
return instance;
}
}
you should try Singleton pattern
for request response.
You must set uses permission in the AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
For my experience
Connection Refused
is caused by :
a|- You don´t have access because probably you are under a Proxy and you need credentials to establish a connection.
b|- You need to add the persmission for connection inside your AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" />
精彩评论