尝试通过抽搐头加载特定的api。该代码过去一直有效,但实际上仍然有效,但是正在拉动我已替换的另一个用户。
尝试使用android volley url进行字符串转换,尝试使用Variable 试图清除代码,应用程序和设备中的缓存 这似乎与凌空抽射有关,但我似乎无法清除。
我不认为这与api相关,否则也不会获取旧信息。或至少在清除缓存后不起作用。
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
queue.getCache().clear();
String url = "https://api.twitch.tv/helix/users?login=Twitchuser";
// Request a string response from the provided URL.
final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(com.android.volley.Request.Method.GET, url, null, new
Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject jsonObject = response;
JSONArray JA = jsonObject.getJSONArray("data");
for (int i = 0; i < response.length(); i++) {
JSONObject object = JA.getJSONObject(i);
String bio = object.getString("description");
mTextView2.append(bio);
}
JSONObject jsonObject2 = response;
JSONArray JA2 = jsonObject2.getJSONArray("data");
for (int i = 0; i < response.length(); i++) {
JSONObject object = JA2.getJSONObject(i);
String name =
object.getString("display_name");
mTextView.append(name);
}
JSONObject jsonObject3 = response;
JSONArray JA3 = jsonObject3.getJSONArray("data");
for (int i = 0; i < response.length(); i++) {
JSONObject object = JA3.getJSONObject(i);
String Image =
object.getString("profile_image_url");
new
DownLoadImageTask(mImageView).execute(Image);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
mTextView.append("Welcome Guest");
Log.e("VOLLEY", "ERROR");
}
})
{ //this is the part, that adds the header to the request
@Override
public Map<String, String> getHeaders() {
Map<String, String> params = new HashMap<String, String>();
params.put("Client-ID", "Client id");
params.put("content-type", "application/json");
return params;
}
};
MySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest);
应该获取抽搐的用户名,描述和徽标,并显示在android应用内的卡片上。可以,但是对于输入的旧用户而言。