Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Google vision not read codebar only in huawei

$
0
0

Hi,

I need some help,

in my app i use Visio api and works fine in almost all the diveces but i am having this trace

05-22 17:15:39.903 W/DynamiteModule( 2125): Local module descriptor class for com.google.android.gms.vision.dynamite not found.
05-22 17:15:39.912 I/DynamiteModule( 2125): Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:1702
05-22 17:15:39.912 I/DynamiteModule( 2125): Selected remote version of com.google.android.gms.vision.dynamite, version >= 1702

i have this to read barcodes

 [Activity(Label = "Scanner", Theme = "@style/MainTheme")]
    public class Vision_scanner : AppCompatActivity, ISurfaceHolderCallback, IProcessor,Scanner_Vision
    {
        SurfaceView surfaceView;
        TextView txtResult;
        BarcodeDetector barcodeDetector;
        CameraSource cameraSource;
        const int RequestCameraPermisionID = 1001;
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            switch (requestCode)
            {
                case RequestCameraPermisionID:
                    {
                        if (grantResults[0] == Permission.Granted)
                        {
                            if (ActivityCompat.CheckSelfPermission(ApplicationContext, Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
                            {
                                //Request Permision  
                                ActivityCompat.RequestPermissions(this, new string[]
                                {
                                   Manifest.Permission.Camera
                                }, RequestCameraPermisionID);
                                return;
                            }
                            try
                            {
                                cameraSource.Start(surfaceView.Holder);
                            }
                            catch (InvalidOperationException)
                            {
                            }
                        }
                    }
                    break;
            }
        }

        protected override void OnCreate( Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                SetContentView(Resource.Layout.Scanner);
                surfaceView = FindViewById<SurfaceView>(Resource.Id.cameraView);
                txtResult = FindViewById<TextView>(Resource.Id.txtResult);

                barcodeDetector = new BarcodeDetector.Builder(this)
                    .Build();

                cameraSource = new CameraSource
                    .Builder(this, barcodeDetector)
                    .SetRequestedPreviewSize(640, 480)
                    .SetAutoFocusEnabled(true)
                    .Build();

                surfaceView.Holder.AddCallback(this);
                barcodeDetector.SetProcessor(this);

            }
            catch (Exception EX)
            {
                EX.ToString();
            }
        }

        public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
        {
        }

        public void SurfaceCreated(ISurfaceHolder holder)
        {
            if (ActivityCompat.CheckSelfPermission(ApplicationContext, Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
            {
                //Request Permision  
                ActivityCompat.RequestPermissions(this, new string[]
                {
                    Manifest.Permission.Camera
                }, RequestCameraPermisionID);
                return;
            }
            try
            {
                cameraSource.Start(surfaceView.Holder);
            }
            catch (InvalidOperationException)
            {
            }
        }

        public void SurfaceDestroyed(ISurfaceHolder holder)
        {
            cameraSource.Stop();
        }

        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;
            if (qrcodes.Size() != 0)
            {
                txtResult.Post(() =>
                {                    
                    App.variablesGlovales.CodigoBarras = ((Barcode)qrcodes.ValueAt(0)).RawValue;

                    if (App.variablesGlovales.campoCodigo == "Placa")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "Placa", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if(App.variablesGlovales.campoCodigo == "Serie")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "Serie", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if (App.variablesGlovales.campoCodigo == "PlacaAF")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "PlacaAF", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if (App.variablesGlovales.campoCodigo == "SerieAF")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "SerieAF", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }           

                    Finish();                    
                });
            }
        }

only in huawei devices

please help

thanks


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>