Here is part of my Activity codes:
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
IParser = new ImageParser(MainActivity.this, EarthqpicUrl);
IParser.execute();
}
});
And this is part of my AsyncTask Codes:
AsyncResponse lempar; *//this is An interface*
public ImageParser(Context actv, String EarthqpicUrl){
this.actv=actv;
this.EarthqpicUrl=EarthqpicUrl;
this.lempar = (AsyncResponse) actv;
}
This is the interface code:
import android.graphics.Bitmap;
public interface AsyncResponse {
public void processFinish(Bitmap output);
}
I use the same code for parsing a JSONData, It works. But when I use the same constructor after some modification like class name, it show an error while debugging:
Thread [<1> main] (Suspended (Exception ClassCastException))
ImageParser.<init>(Context, String) Line:25
MainActivity$1.onCllick(View) line: 23
what's wrong with this code? Can somebody help me? Thanks a lot
These is part of codes I use in JSONParser:
AsyncResponse delegate;
public JSONParser(Context actv,String url){
this.actv=actv;
this.url = url;
this.delegate = (AsyncResponse) actv;
}
same as JSONParser, I use an interface named AsyncResponse.