using following code snippet to find similar faces via asynch task
class DetectionTask extends AsyncTask<InputStream, String, Face[]> {
private boolean mSucceed = true;
int mRequestCode;
DetectionTask(int requestCode) {
mRequestCode = requestCode;
}
@Override
protected Face[] doInBackground(InputStream... params) {
FaceServiceClient faceServiceClient = SampleApp.getFaceServiceClient();
try{
publishProgress("Detecting...");
// Start detection.
return faceServiceClient.detect(
params[0], /* Input stream of image to detect */
true, /* Whether to return face ID */
false, /* Whether to return face landmarks */
/* Which face attributes to analyze, currently we support:
age,gender,headPose,smile,facialHair */
null);
} catch (Exception e) {
mSucceed = false;
publishProgress(e.getMessage());
addLog(e.getMessage());
return null;
}
}
using this following class to generate a Face service client This is my code for Sample App
public class SampleApp extends Application {
@Override
public void onCreate() {
super.onCreate();
sFaceServiceClient = new FaceServiceRestClient(getString(R.string.subscription_key));
}
public static FaceServiceClient getFaceServiceClient() {
return sFaceServiceClient;
}
private static FaceServiceClient sFaceServiceClient;
}
While debugging I found that sFaceServiceClient is always null when calling SampleApp.getFaceServiceClient() so I don't get any response due to null object . I tried using different keys via multiple accounts but of no help . The same issue still persists. A help will be appreciated