android-networking

Checking Device has internet connection

蓝咒 提交于 2019-12-14 04:23:25
问题 I followed this Keep checking if Device has internet connection to check internet connectivity using BroadcastReceiver, the problem is how to call this registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); from main activity 回答1: Try this: if(isNetworkStatusAvialable(getApplicationContext())) { }else { public static boolean isNetworkStatusAvialable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService

Connect Android Tablets via cable/wire

女生的网名这么多〃 提交于 2019-12-14 00:41:39
问题 I have 6 android tablets, and i want to connect them via a cable/wire, so that they can send messages to one another. (perhaps similar to way PCs may be networked with each other) Once connected, apps running on the devices can exchange messages with each other via sockets or any other protocol. What are the best options? Connecting devices over wi-fi is an option too, but then internet is not guaranteed in this scenario, and devices may be very far of from each other for any near field

How to get device independent local date and time Android

浪尽此生 提交于 2019-12-13 16:21:38
问题 My application is time dependent and I don't want change in device date and time affect my application, like if user deliberately set device date to any previous date . Is there any way to get current date and time when user is connected to mobile network or WiFi I don't want to use GPS. 回答1: Javadoc of the SystemClock class describe different ways of counting elapsed time for various scenarios and conditions. In your case you have to use long time = SystemClock.elapsedRealtime(); Return the

Network request doesn't work when uploading a file

久未见 提交于 2019-12-13 04:28:47
问题 I am facing a problem which I don't know how to solve. GetDataTask works fine. But when I am uploading a file, the request is sent but the response comes only after the file upload is finished! GetDataTask and UploadTask run asynchronously using AsyncTask. Any idea why it doesn't work and why the response doesn't come back when the file is uploading. Is there another way to realize this? The problem is, it is supposed to run in a parallel but unfortunately they are running synchronously . I

Android app fails to get access to the network

血红的双手。 提交于 2019-12-13 04:17:17
问题 I am trying to connect to a chat server on the internet from an Android app so first I test whether I have contact with the server from an AsyncTask: @Override protected Void doInBackground(SocketAndEditText... soEd) { try{ InetAddress address1 = InetAddress.getByName("130.237.161.23"); boolean reachable = address1.isReachable(4456); //... } catch (Exception e) { //... } } When I run the above code the variable reachable gets the value false but when I run the same code as a simple Java

Should I choose Boost Asio or Aysnc Socket threads in Android?

会有一股神秘感。 提交于 2019-12-12 10:57:40
问题 I am in process of developing an network based UI app for Android which would perform following kind of functionalities Needs to communicate with TCP servers running on n/w based embedded devices (>100 at a time). Polling these devices at regular intervals for fetching updated information Sending and receiving information from those devices All above information would be controlled and managed by application's UI Considering above situations, the app would probably have to spawn multiple

Can java.util.zip.GZIPInputStream.close cause android.os.NetworkOnMainThreadException

徘徊边缘 提交于 2019-12-12 05:25:28
问题 The App works fine on the 2.2.1 and 2.2 but is causing the following error on 4.0.3 android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1178) at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:163) at libcore.io.IoBridge.recvfrom(IoBridge.java:503) at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488) at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46) at java.net.PlainSocketImpl$PlainSocketInputStream.read

How can I regularly update a database of content on an Android app?

混江龙づ霸主 提交于 2019-12-12 04:38:01
问题 So the app is for a Parrot Rescue. It will contain profiles for each of the birds that we currently have for adoption. So a picture of the bird, and then basic info about the bird. It needs to be regularly updated as the birds are adopted out and new ones come in. What route should I go? My main concern is that I want it to be relatively easy to update so that some of the less technically inclined could use it, as I won't always be available to help them. 回答1: Instead of loading a new version

Android WifiManager making a phantom connection?

亡梦爱人 提交于 2019-12-12 03:41:37
问题 I'm using WifiManager to test for the presence of a particular SSID and verify a given WPA password, but I'm getting a weird result. The code looks like this: WifiConfiguration wc = new WifiConfiguration(); // init ssid and password as Strings ... wc.SSID = "\"" + ssid + "\""; wc2.preSharedKey = "\"" + password + "\""; wc.hiddenSSID = true; wc.status = WifiConfiguration.Status.ENABLED; wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); wc.allowedGroupCiphers.set(WifiConfiguration

How do I pass a bodyparameter for Rx2AndroidNetworking for get requests?

强颜欢笑 提交于 2019-12-11 12:44:05
问题 I am working on retrieving some endpoints in a helper class with Rx2AndroidNetworking. However, there is no way I can pass "addBodyParameter" with get requests (only works for post and put requests". I was wondering if there's a way around it? My postman query looks like this (which does return proper results once i add the "my_session_token" in the body as shown below: However, I am not sure how that pans out with my code. My code for retrieving it is as follows: @Override public Single