android-networking

Why does multicast reception not work on some Android devices?

人走茶凉 提交于 2019-11-29 14:00:10
问题 It seems multicast reception does not work on some Android devices. I can not receive multicast with 4 out of 13 test devices. On those 4 devices it seems the app does not send the IGMP request to join the multicast group. The code to receive the multicast looks like so: WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE); WifiManager.WifiLock wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, TAG); WifiManager.MulticastLock

Android Volley MalformedURLException Bad URL

有些话、适合烂在心里 提交于 2019-11-29 13:23:52
After making a second network request using Volley , I always get this error. It doesn't seem to matter what the url I put in is. Volley always claims it is malformed. 08-04 20:16:26.885 14453-14470/com.thredup.android E/Volley﹕ [994] NetworkDispatcher.run: Unhandled exception java.lang.RuntimeException: Bad URL java.lang.RuntimeException: Bad URL at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:127) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110) Caused by: java.net.MalformedURLException: Protocol not found: at java.net.URL.<init>(URL.java

How To Resolve Network Host Names From IP Address

家住魔仙堡 提交于 2019-11-29 12:26:53
I am working on wifi based chat engine and I was able to retrieve the list of hosts connected to current wifi network by followin this link and now got list of devices with ip addresses but i need host name from the ip address and tried following InetAddress inetAddr; try { inetAddr = InetAddress.getByName(host.hostname); String hostname = inetAddr.getHostName(); String canonicalHostname = inetAddr.getCanonicalHostName(); holder.computerName.setText("Canonical : "+host.hostname); } catch (Exception e) { e.printStackTrace(); } Here the host name and canonical host name both are displaying ip

Android: How to Know an IP Address is a Wifi IP Address?

老子叫甜甜 提交于 2019-11-29 11:46:06
I want to know the whether IP address of an Android device is Data IP or Wifi IP. 1) Device as is connected to 3G first, now the Device will be assigned to Network IP. 2) Later Device connected to WIFI , now the Device will be assigned to WIFI IP. 3)Any Android API which will let us know an IP Address is a Wifi IP Address or Network IP?? Was Using below in 2.3.5 and things were fine, but in 4.0.3 ICS has some issues.. /** * Is the IP Address a a Wifi Ip Address. * @param ipAddr * @return boolean */ public boolean isWifiIp(byte[] ipAddr){ try{ WifiManager mgr = (WifiManager)mCxt

Why would URLConnection timeout after 6+ minutes instead of 5 seconds?

白昼怎懂夜的黑 提交于 2019-11-29 10:23:03
I am copying this method verbatim from my application, which isn't complete yet but it does attempt to provide me with a timeout stack trace if things don't go smoothly: protected boolean isHttpAlive() { boolean isHttpOk = false; HttpURLConnection httpConnection = null; try { URL gurl = new URL("http://www.amazon.com/"); URLConnection connection = gurl.openConnection(); connection.setConnectTimeout(5 * 1000); // 5 seconds! httpConnection = (HttpURLConnection) connection; int responseCode = httpConnection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) isHttpOk = true; } catch

UDP broadcast packets not received in sleep mode

和自甴很熟 提交于 2019-11-29 08:48:31
My Android application periodically sends and receives UDP broadcast messages on the WiFi LAN. When the display is on, everything works fine and all messages are sent and received correctly. When the display goes to sleep the application however stops receiving UDP broadcast messages (but still sends them). Acquiring the WiFiLock (as well as a Multicast Lock) does not seem to make any difference and my wifi sleep policy is set to WIFI_SLEEP_POLICY_NEVER. This is an issue on Android 2.3.3 and 2.3.5 (Samsung galaxy SII phones) but not an issue on an old HTC Hero running cyanogen mod with android

Volley framewok request keeps objects in memory

佐手、 提交于 2019-11-28 12:25:56
问题 I'm making a volley request in this way: public void makeRequest(BaseRequest request, Response.Listener<JSONObject> responseListener, Response.ErrorListener errorListener) { if (Constants.DEBUG) Log.i(TAG, "Sending: " + request.getUrlRequest()); JsonObjectRequest jsObjRequest = new JsonObjectRequest(METHOD, request.getUrlRequest(), null, responseListener, errorListener); // disable cache jsObjRequest.setShouldCache(false); jsObjRequest.setTag(mTag); mQueue.add(jsObjRequest); } mTag is a Class

Login to website through Jsoup post method not working

こ雲淡風輕ζ 提交于 2019-11-28 12:25:34
问题 I have the following code which I am using to login to a website programmatically. However, instead of returning the logged in page's html (with user data info), it returns the html for the login page. I have tried to find what's going wrong multiple times but I can't seem to find it. public class LauncherClass { static String username = "----username here------"; //blocked out here for obvious reasons static String password = "----password here------"; static String loginUrl = "https:/

Why is HttpUrlConnection throwing an SSLException while on a mobile data connection?

感情迁移 提交于 2019-11-28 09:04:32
When using Android's HttpUrlConnection library to make an HTTPS request, I sometimes see the following exception being thrown: javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x5c1b18a0: I/O error during system call, Connection reset by peer at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method) at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:395) ... After digging into the issue a bit, I've learned that Everything works fine on wifi The exception is only thrown when the device is on a mobile data connection

android how to get indicate when the internet connection is lost?

久未见 提交于 2019-11-28 08:23:53
I'm developing an android application and I want to get a notification when the internet (wifi or packet data connection) connection is lost. On my approach I can get the status of the connection as: private boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); } while having this in the Manifest: <uses-permission android:name="android.permission.ACCESS_NETWORK