I am using AsyncTask
to make an API call. My AsyncTask
is supposed to send two images to a facial recognition service and return a Double
contained in the JSON response from the service.
However, I keep getting this error regarding onPostExecute()
:
Error:(44, 5) error: method does not override or implement a method from >a supertype
I don't understand why I get this error.
Here is my AsyncTask
subclass:
public class KairosManager extends AsyncTask<Bitmap, Void, JSONObject> {
// MainActivity Context
private Context mContext;
public KairosManager(Context context){
mContext = context;
}
// Call Kairos API and return JSONObject response to doInBackground()
public JSONObject compareImages(Bitmap bm1, Bitmap bm2){
// Kairos Call here!
return jsonResponse;
}
// Take both images in the array and call compareImages which calls the service.
@Override
protected JSONObject doInBackground(Bitmap... params){
Bitmap bm1 = params[0];
Bitmap bm2 = params[1];
return compareImages(bm1, bm2);
}
// Parse JSONObject response and return 'confidence' value to MainActivity
@Override
protected Double onPostExecute(JSONObject result){
try{
JSONArray TwoImages = result.getJSONArray(IMAGES);
JSONObject image = TwoImages.getJSONObject(0);
JSONObject subimage = image.getJSONObject(TRANSACTION);
Double confidence = subimage.getDouble(CONFIDENCE);
Log.d("Percent: ", confidence.toString());
return confidence;
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Here is my MainActivity:
Bitmap bm1 = ((BitmapDrawable) image1.getDrawable()).getBitmap();
Bitmap bm2 = ((BitmapDrawable) image2.getDrawable()).getBitmap();
KairosManager myKairosManager = new KairosManager(this);
myKairosManager.execute(bm1, bm2);