volley

parsing data from JSON using Volley in Android

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I tried parsing JSON data from " https://api.instagram.com/v1/media/popular?client_id= " + clientId; or any other url, in a tons of different ways! Used couple of JSONParsers, tutorials, readers .. everything, but still can't to get anything from those urls. Now I am using Volley library and still can't get it to work, here is my code and everything you need, if anyone has any ideas , please share them. public void LoadPictures() { mRequestQueue = Volley.newRequestQueue(this); mRequestQueue.add(new JsonObjectRequest(urlInst, null, new

Android Volley - BasicNetwork.performRequest: Unexpected response code 400

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Problem statement: I am trying to access an REST API that will return a JSON object for various HTTP status codes (400, 403, 200 etc) using Volley. For any HTTP status other than 200, it seems the 'Unexpected response code 400' is a problem. Does anyone have a way to bypass this 'error'? Code: protected void getLogin() { final String mURL = "https://somesite.com/api/login"; EditText username = (EditText) findViewById(R.id.username); EditText password = (EditText) findViewById(R.id.password); // Post params to be sent to the server HashMap

Android Volley框架的几种post提交请求方式

旧巷老猫 提交于 2019-12-03 02:48:31
首先简单描述一下Google的Android开发团队在2013年推出的一个网络通信框架Volley.它的设计目标是进行数据量不大,但通信频繁的网络操作,而对于大数据量的网络操作,比如下载文件等,Volley的表现就不尽如人意。 在app开发中,我们最常见的就是从app客户端向服务端发一个http请求.对于两种基本的web请求方式get和post来说,get请求方式相对比较简单,在此略过不表.本文重点描述一下通过volley进行几种post提交的方式. 1.客户端以普通的post方式进行提交,服务端返回字符串 RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext()); StringRequest stringRequest = new StringRequest(Request.Method.POST,httpurl, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d(TAG, "response -> " + response); } }, new Response.ErrorListener() { @Override public void

Android Volley double post when have slow request

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a problem with Volley POST request on slow network. Everytime I see BasicNetwork.logSlowRequests in my LogCat, my POST request is executed twice or more resulting multiple (2 or more) postings for 1 request. I already set the retry policy to 0, but It doesn't help. This is my LogCat 03-16 01:31:35.674: D/Volley(5984): [19807] BasicNetwork.logSlowRequests: HTTP response for request=http://[myserver]/api/places 0xfa7d0c33 NORMAL 1> [lifetime=3824], [size=313], [rc=200], [retryCount=0] 03-16 01:31:35.704: D/Volley(5984): [1]

Android Volley, duplicate Set-Cookie is overridden

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Trying to use Volley lib as a network wrapper for my android application. I have a connection up and running, but the problem is that every time there is multiple "Set-Cookie" headers in the response Volley uses Map that cannot have duplicate keys, and will only store the last Set-cookie header and overwrite the rest. Is there a workaround for this issue? Is there another lib to use? 回答1: I tried overiding classes to fix this but when I had to edit NetworkResponse , I was descending too far down the rabbithole. So I decided to just edit

Android volley error request code 415 with Rest API?

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Server side: import flask import flask.ext.sqlalchemy import flask.ext.restless app = flask.Flask(__name__) app.config['DEBUG'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' SQLALCHEMY_TRACK_MODIFICATIONS=True db = flask.ext.sqlalchemy.SQLAlchemy(app) class Person(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode, unique=True) birth_date = db.Column(db.Date) class Computer(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode, unique=True) vendor = db

Android - cancel Volley request

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Android Volley lib in my project to execute network requests, all works very well but I have some troubles with the "cancel" feature of this lib. I explain my issue.. I've an activity, where I'm executing the request at OnCreate method, the request is called, no problem. But to be sure that the cancel method works, I wanted to test and try 2 things : I fire my request and just after cancel it like this : MySingleton.getMyData("urltocall", getDataListener, requestTag); MySingleton.getRequestQueue().cancelAll(requestTag); This one

Volley out of memory error, weird allocation attempt

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Sometimes randomly Volley crashes my app upon startup, it crashes in the application class and a user would not be able to open the app again until they go into settings and clear app data java.lang.OutOfMemoryError at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:316) at com.android.volley.toolbox.DiskBasedCache.readString(DiskBasedCache.java:526) at com.android.volley.toolbox.DiskBasedCache.readStringStringMap(DiskBasedCache.java:549) at com.android.volley.toolbox.DiskBasedCache$CacheHeader.readHeader

Http Status Code in Android Volley when error.networkResponse is null

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Google Volley on the Android platform. I am having a problem in which the error parameter in onErrorResponse is returning a null networkResponse For the RESTful API I am using, I need to determine the Http Status Code which is often arriving as 401 (SC_UNAUTHORIZED) or 500 (SC_INTERNAL_SERVER_ERROR), and I can occasionally check via: final int httpStatusCode = error.networkResponse.statusCode; if(networkResponse == HttpStatus.SC_UNAUTHORIZED) { // Http status code 401: Unauthorized. } This throws a NullPointerException because

Volley RequestQueue Timeout

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: RequestQueue mRequestQueue = Volley.newRequestQueue(getApplicationContext()); mRequestQueue.add(new JsonObjectRequest(Method.GET, cityListUrl, null, new Listener () { public void onResponse(JSONObject jsonResults) { //Any Call } }, new ErrorListener() { public void onErrorResponse(VolleyError arg0) { //Any Error log } } )); This is my Request Call and i want to change or set timeout for the request . Is it possible anyway ?? 回答1: You should set the request's RetryPolicy : myRequest.setRetryPolicy(new DefaultRetryPolicy( MY_SOCKET_TIMEOUT_MS,