android-networking

Receive xml file is corrupted (on sprint network)?

我的梦境 提交于 2019-12-11 07:51:08
问题 I am having a very strange issue in my android app. I receive xml file from server and perform operation based on xml content. It is working on almost every network for eg. AT&T, Verizon in USA, airtel, vodaphone and others in india.But it not working on sprint network USA. When i tried to find xml content i am getting some byte code or unicode not the plain xml file. I looked for more information i found other also has faced this issue on sprint evdeo. people says turn off byte mobile

android retrofit send array as x-www-form-urlencoded

核能气质少年 提交于 2019-12-11 05:56:49
问题 I'm using retrofit as my network library, and I want to send a JSON array as x-www-form-urlencoded , but I don't know how to do that. Here is my request API : @POST("book") @FormUrlEncoded Call<BookTicket> BookFlight(@Header("Authorization") String authorization, @Header("Content-Type") String content_type, @Field("rootType") Integer rootType , @Field("BookingStep2") ArrayList<JSONObject> BookingStep2 ); Here is a sample request : { "rootType": 1, "BookingStep2": { "OriginFlightSegment": {

Volley Cache returns null when receiving 304

心已入冬 提交于 2019-12-11 03:26:40
问题 I am trying to get Volley to work using its Cache . When I receive a 304 getCacheEntry().data is null even though "cache-control" is set. Here is what I am doing: Volley gets instantiated likes this // Instantiate the cache Cache cache = new DiskBasedCache(c.getCacheDir(), 10 * 1024 * 1024); // 10 MB cap // Set up the network to use HttpURLConnection as the HTTP client. Network network = new BasicNetwork(new HurlStack()); // Instantiate the RequestQueue with the cache and network.

How to set the maximum number of network connections in Retrofit

﹥>﹥吖頭↗ 提交于 2019-12-11 02:55:15
问题 I was going through some AQuery code here and found there's a way to modify the number of network connections in AQuery. Is there a way of doing this in retrofit, and what are the default values for retrofit? /* Settings of Image */ //set the max number of concurrent network connections, default is 4 AjaxCallback.setNetworkLimit(8); //set the max number of icons (image width <= 50) to be cached in memory, default is 20 BitmapAjaxCallback.setIconCacheLimit(50); //set the max number of images

Android SyncAdapter: how to get notified of specific sync happened

人盡茶涼 提交于 2019-12-11 01:47:11
问题 I have the following scenario. I use a SyncAdapter in my app to download data from a server. When the user opens the app I call requestSync() to make sure the latest data are available. When the user requests it I call again requestSync() passing a bundle of the specific datum I want to download. The problem is the following: I can use a SyncStatusObserver to get notified about the status of the download, but that will not tell me which sync is completed: For example: at app start I start a

How to get time from Network in Android

无人久伴 提交于 2019-12-10 19:39:37
问题 In my app I want to use the Network Time and not the time of device. It is the requirement of my app that time should be correct. I'm trying to get the time from NTS server but loader keeps on running and does not stop I waited for more than 30 mins but still I don't get anything. I want to know is there any other method for getting the from network because I don't thing getting time from network takes so much time. public class MainActivity extends Activity { public static final String TIME

UnknownHostException suddenly starts happening, and doesn't go away (on phone, not in emulator)

僤鯓⒐⒋嵵緔 提交于 2019-12-10 17:58:06
问题 I have written an app that hits a website for data every hour or so. In most cases, this works just great. However, I've had repeated issues lately where suddenly the app stops updating the data. In other words, the app is working just great, accessing the website and pulling down data...and then suddenly it won't anymore. I finally tracked it down to a "java.net.UnknownHostException: www.mysite.com". The thing is...the device (this is on devices, NOT the emulator) can still access the

Android Find the device's ip address when it's hosting a hotspot

跟風遠走 提交于 2019-12-10 02:39:51
问题 I need to find the device's ip address when it's hosting a hotspot. I've used this code so far : //if is using Hotspot for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); if (intf.getName().contains("wlan")) { for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() &

Android emulator, network state and internet access

自作多情 提交于 2019-12-08 10:34:09
问题 I was trying to test the network state of my emulator using following code and allowing it android.permission.ACCESS_NETWORK_STATE : public class Main extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); boolean wified = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)

Keep checking if Device has internet connection

被刻印的时光 ゝ 提交于 2019-12-08 10:10:42
问题 As title states I wanted to ask, how can I keep checking if the device has internet connection? I use the following class: import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; public class checkConnection { private static checkConnection instance = new checkConnection(); static Context context; ConnectivityManager connectivityManager; NetworkInfo wifiInfo, mobileInfo; boolean connected = false; public static