使用firebase MLkit的文本识别仅调用OnFailure()方法。为什么?

时间:2019-03-21 08:11:42

标签: android firebase firebase-mlkit

尽管我从firebase控制台获取了代码,并且我很确定firebase正确集成了

FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
    FirebaseVisionTextRecognizer detector = FirebaseVision.getInstance()
            .getOnDeviceTextRecognizer();


    Task<FirebaseVisionText> result =
            detector.processImage(image)
                    .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
                        @Override
                        public void onSuccess(FirebaseVisionText firebaseVisionText) {
                            // Task completed successfully
                            // ...

                            Toast.makeText(MainActivity.this, "Inn On Success Method", Toast.LENGTH_SHORT).show();
                        }
                    })
                    .addOnFailureListener(
                            new OnFailureListener() {
                                @Override
                                public void onFailure(@NonNull Exception e) {
                                    // Task failed with an exception
                                    // ...

                                    Toast.makeText(MainActivity.this, "Inn On failure Method", Toast.LENGTH_SHORT).show();
                                }
                            });

我添加了吐司消息只是为了检查执行哪种方法。

0 个答案:

没有答案