大佬教程收集整理的这篇文章主要介绍了来自 JSONArrayRequest,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 AndroID studio 中有一个脚本,当启动一个新活动时,该活动从网页请求 XML 数据, 我做了一个 JsONArrayrequest 直到最近才起作用,我不记得我触摸了什么,我还在学习...... 当开始 geTinfo 调用开始请求时,我有一个等待请求结束的回调接口。 但是当实例化一个新的 JsonArrayrequest 时,他会忽略 OnResponse 和 ErrorResponse 并跳转到 mrequestQueue.add(request)。 url 是正确的,我尝试通过从 deBUG 中的值复制它来打开它
我有一个在活动开始时发送通知的方法:
@OverrIDe
protected voID onCreate(Bundle savedInstanceStatE){
try{
geTinfo(new VolleyCallBACk(){
public voID Onsuccess(){
sendlocalnotification(myClass.getname(),"pluto");
}});
}
catch (ExecutionException | InterruptedException E){
e.printstacktrace();
}}
发送通知的方法:
private voID sendlocalnotification(String titolo,String text)
{
Notification notification = new NotificationCompat.builder(getApplicationContext(),"chAnnelX")
.setsmallicon(androID.R.drawable.ic_dialog_info)
.setContenttitle(titolo)
.setContentText(text)
.setDefaults(Notification.DEFAulT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.build();
notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(this);
int id = (int) ((new Date().getTime() / 1000L) % Integer.max_value);
notificationmanager.notify(ID,notification);
}
以及从页面中提取数据并将其保存在 Beam 类中的方法。
但现在忽略 OnResponse 和 ErrorResponse。
private voID geTinfo(final VolleyCallBACk CallBACk) throws ExecutionException,InterruptedException
{
requestQueue mrequestQueue = VolleySingleton.geTinstance().getrequestQueue();
String url = getUrl();
JsONArray JsonArray = new JsONArray();
JsonArrayrequest request = new JsonArrayrequest(request.Method.GET,url,JsonArray,new Response.Listener<JsONArray>(){
@OverrIDe
public voID onResponse(JsONArray responsE){
JsONObject object;
myClass = new MyClass();
for (int index = 0; index < response.length(); index++)
try{
object = response.getJsONObject(indeX);
if (!object.getBoolean("exist")
&& object.geTint("_ID") != 0){
myClass.set_ID(object.getString("_ID"));
myClass.set_name(object.getStrig("name"));
myClass.set_exist(object.getStrig("exist"));
callBACk.onsuccess();
break;}
} catch (JsONException E){
e.printstacktrace();}
}
},new Response.ErrorListener(){
@OverrIDe
public voID onErrorResponse(VolleyError err){
Toast.makeText(getApplicationContext(),"Download ERROR",Toast.LENGTH_SHORT).show();}
});
mrequestQueue.add(request);}
xml 数据的复制:
<ArrayOfXXX xmlns:i="http://www.w3.org/2001/XMLscheR_974_11845@a-instance" xmlns="http://scheR_974_11845@as.datacontract.org/XXXXX">
<nameObject>
<name/>
<_ID>012345</_ID>
<exist>false</exist>
</nameObject>
<nameObject>
<name/>
<_ID>0</_ID>
<exist>false</exist>
</nameObject>
</ArrayOfXXX>
我不知道发生了什么......
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的来自 JSONArrayRequest全部内容,希望文章能够帮你解决来自 JSONArrayRequest所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。