android-networking

How to return response header field to main method using Google Volley for HTTP GET request in Android / Java?

[亡魂溺海] 提交于 2019-12-07 01:15:27
问题 I'm using google volley for networking in android. I will make a http GET request and need to return a response header value. I found some answers on stack overflow to access the header fields, but don't know how to return it to my calling spot. Please have a look at my code, I put four numbers in it to explain my problem. At (1) I can print out the value which I need. Than I've tried to save it in a class attribute (2) and there is no error in the IDE. If I want to return it from there (3),

Any good example for working with UNKNOWN CA signed certificate(like pkcs12) in android

心已入冬 提交于 2019-12-06 18:05:16
问题 I am working on android application, which requires to communicate with server over ssl. Any good example to work with pkcs12 certificates in android using HttpsUrlConnection 回答1: After doing some modifications to the code posted by @EpicPandaForce, i was able to successfully run the code. Changes: 1. KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("X509"); to KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509"); to get rid of exception: java

CONNECTIVITY_CHANGE deprecated in target of Android N

可紊 提交于 2019-12-06 17:23:58
问题 I am getting warning of deprecated declaration of Broadcast Receiver. <!-- NETWORK RECEIVER... --> <receiver android:name=".utils.NetworkUtils" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> WARNING: Declaring a broadcastreceiver for android.net.conn.CONNECTIVITY_CHANGE is deprecated for apps targeting N and higher. In general, apps should not rely on this broadcast and instead use JobScheduler or GCMNetworkManager. Is there any

how to reroute all IP traffic (pref. at the network layer) in Android 3.x

让人想犯罪 __ 提交于 2019-12-06 14:54:24
问题 This is specific to Android 3.0/3.1 In order to implement a cloud security layer, I would like to reroute all IP traffic destined for certain ports through my custom cloud server which would then serve up the required pages if they don't pose any threat. The reasons I would like to do this are: 1. The applications running on Android would still continue their interaction with regular requests and wouldn't require any modifications 2. Better security. It should not be possible for a user to

how to send post request with data in Volley?

£可爱£侵袭症+ 提交于 2019-12-06 11:52:13
问题 This is my android code JSONObject params = new JSONObject(); params.put("username","rajesh@gmail.com"); params.put("password","hellothere"); JsonObjectRequest loginRequest = new JsonObjectRequest( Request.Method.POST, "http://192.168.2.67/tmp/test.php", params, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject jsonObject) { Log.d("",""); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Log.d("",""); } });

How to retry a consumed Observable?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 09:29:06
I am trying to re-execute a defined observable that failed. Using Retrofit2 and RxJava2 together i want to retry a specific request with its subscription and behavior when clicking a button. is that possible? service.excecuteLoginService(url, tokenModel, RetrofitManager.apiKey) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(....) An option is to create Publisher, which emission is controlled by your button. final PublishSubject<Object> retrySubject = PublishSubject.create(); service.excecuteLoginService(url, tokenModel, RetrofitManager.apiKey)

Sync device data with web-server

我是研究僧i 提交于 2019-12-06 07:55:07
I have data in my application which must be updated on the server on the basis of network availability. I store this data on a local database on android using sqlite. Currently the idea is: Data should be inserted on the local sqlite database A service should be waiting as soon as the data is inserted it checks the network availability and send it to the server and wait for success response. If the response true is received from the server it should update the sync status of that sqlite row and move to the next row to send the data. I wanted to find out the best way to queue this data to send

Network traffic monitoring per android application

喜夏-厌秋 提交于 2019-12-06 04:06:11
问题 I was wondering if I can do network traffic monitoring per android application? Basically see which app is receiving/sending how much data? I know there are many apps which already do that but I want to know how to do it. 回答1: Well you surely can. A very simple way is to use the TrafficStats class. It can manage per app (more formally, per UID) But the problem is, it can return UNSUPPORTED . When this happens, I don't think you will have some easy (i.e. using the high level Java language)

Upload and Download rate profiling in Android [closed]

扶醉桌前 提交于 2019-12-05 06:23:12
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 3 years ago . I'm trying to develop an Android app to measure the upload and download speed of my network, which probably I would need to run and profile it every 2 seconds or so. SpeedTest.net app is an ideal app working similarly, however, it is not open-source. Moreover, I would need it to be run every 2 seconds. It takes couple of seconds to finish test. How can I do that? Currently I'm

How to get the name of operator which is connected to internet in dual sim android phone?

别来无恙 提交于 2019-12-05 05:54:51
I have made a network monitor app. Here I have successfully implemented all the things. I have the dual sim android phone. I know how to get the name of operator. But I want to that which sim is connected to internet? I have used this code, only to show user that the device is connected through mobile data. I want to be more specific that the device is currently using which operator's internet. public static String isInternetConnected (Context ctx) { ConnectivityManager connectivityMgr = (ConnectivityManager) ctx .getSystemService(CONNECTIVITY_SERVICE); NetworkInfo wifi = connectivityMgr