I get no response when request string to XML API . Here's the code :
String url = "http://www.w3schools.com/xml/note.xml"
String url2 = "http://api.json.request"
RequestQueue queue = Volley.newRequestQueue(context);
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String _response) {
Log.d("json=>",_response);
res = _response;
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Error handling
Log.d("jsone=>", error.toString());
}
});
queue.add(stringRequest);
i have tested it using Google API (url2) , but it's fine. Maybe Android Volley run too slow when try to get response, but seeing log i didnt get it at all.
The Log when initiate request :
01-28 10:57:05.253 21424-21424/com.merahjambutech.zuki.deteksi I/Timeline: Timeline: Activity_launch_request time:26387334
01-28 10:57:05.353 21424-21424/com.merahjambutech.zuki.deteksi D/pre=: 0
01-28 10:57:05.433 21424-21424/com.merahjambutech.zuki.deteksi W/ImageLoader: Try to initialize ImageLoader which had already been initialized before. To re-init ImageLoader with new configuration call ImageLoader.destroy() at first.
01-28 10:57:05.463 21424-21470/com.merahjambutech.zuki.deteksi D/dalvikvm: GC_FOR_ALLOC freed 503K, 11% free 24699K/27632K, paused 29ms, total 29ms
01-28 10:57:05.483 21424-21470/com.merahjambutech.zuki.deteksi I/dalvikvm-heap: Grow heap (frag case) to 29.898MB for 3686416-byte allocation
01-28 10:57:05.543 21424-21424/com.merahjambutech.zuki.deteksi W/ImageLoader: Try to initialize ImageLoader which had already been initialized before. To re-init ImageLoader with new configuration call ImageLoader.destroy() at first.
01-28 10:57:05.573 21424-21547/com.merahjambutech.zuki.deteksi D/dalvikvm: GC_FOR_ALLOC freed 173K, 10% free 28324K/31236K, paused 15ms, total 15ms
01-28 10:57:05.573 21424-21547/com.merahjambutech.zuki.deteksi I/dalvikvm-heap: Grow heap (frag case) to 33.438MB for 3686416-byte allocation </note>
01-28 10:57:05.643 21424-21424/com.merahjambutech.zuki.deteksi I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@42485428 time:26387720
please ensure that you add permission in manifest
file:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.