java - Android must implement the inherited abstract method -
i have downloaded project function works well, when coppied function project, errors :
the type
new asynchttpresponsehandler(){}
must implement inherited abstract methodasynchttpresponsehandler.onsuccess(int, header[], byte[])
the method
onsuccess(string)
of typenew asynchttpresponsehandler(){}
must override or implement supertype methodthe method
onfailure(int, throwable, string)
of typenew asynchttpresponsehandler(){}
must override or implement supertype method
i tried tips this question nothing helped. possible solution ?
public void syncsqlitemysqldb(){ //create asychttpclient object asynchttpclient client = new asynchttpclient(); requestparams params = new requestparams(); arraylist<hashmap<string, string>> userlist = controller.getallusers(); if(userlist.size()!=0){ if(controller.dbsynccount() != 0){ prgdialog.show(); params.put("usersjson", controller.composejsonfromsqlite()); client.post("http://techkeg.tk/sqlitemysqlsync/insertuser.php",params ,new asynchttpresponsehandler() { @override public void onsuccess(string response) { system.out.println(response); prgdialog.hide(); try { jsonarray arr = new jsonarray(response); system.out.println(arr.length()); for(int i=0; i<arr.length();i++){ jsonobject obj = (jsonobject)arr.get(i); system.out.println(obj.get("id")); system.out.println(obj.get("status")); controller.updatesyncstatus(obj.get("id").tostring(),obj.get("status").tostring()); } toast.maketext(getapplicationcontext(), "db sync completed!", toast.length_long).show(); } catch (jsonexception e) { toast.maketext(getapplicationcontext(), "error occured [server's json response might invalid]!", toast.length_long).show(); e.printstacktrace(); } } @override public void onfailure(int statuscode, throwable error, string content) { prgdialog.hide(); if(statuscode == 404){ toast.maketext(getapplicationcontext(), "requested resource not found", toast.length_long).show(); }else if(statuscode == 500){ toast.maketext(getapplicationcontext(), "something went wrong @ server end", toast.length_long).show(); }else{ toast.maketext(getapplicationcontext(), "unexpected error occcured! [most common error: device might not connected internet]", toast.length_long).show(); } } }); }else{ toast.maketext(getapplicationcontext(), "sqlite , remote mysql dbs in sync!", toast.length_long).show(); } }else{ toast.maketext(getapplicationcontext(), "no data in sqlite db, please enter user name perform sync action", toast.length_long).show(); } }
you cannot make new signature overriden methods, according error , api
methods must have same signature super class/interface:
it follows compile-time error if [...] method signature override-equivalent [...] has different return type or incompatible throws clause.
in case signatures must be:
public void onsuccess(int statuscode, header[] headers, byte[] responsebody) { // got response } public void onfailure(int statuscode, header[] headers, byte[] responsebody, throwable error) { // response failed :( }
not:
public void onsuccess(string response) { public void onfailure(int statuscode, throwable error, string content) {
resuming.... declare methods described above , in asynchttpresponsehandler
api , addapt them achieve needs.
Comments
Post a Comment