0

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

Naman
  • 39
  • 11
  • The obvious question is whether `SampleApp.onCreate` is being called or not. Can you confirm? If not, take a look at http://stackoverflow.com/questions/6858158/custom-android-app-application-not-firing-oncreate-event – cthrash Apr 21 '17 at 04:10
  • @cthrash : thanks a lot very silly mistake . It worked seamlessly – Naman May 08 '17 at 05:48

0 Answers0