blinkcard / blinkcard-android

SDK for scanning and OCR of credit or payment cards. Contains native Android SDK, code samples and documentation.
44 stars 5 forks source link

Getting incompatible type error #11

Closed samirpramanik closed 3 years ago

samirpramanik commented 3 years ago

Hello,

I have implemented Blink Card sdk 2.0.0 using the built-in fragment(RecognizerRunnerFragment). However, when i am trying to replace the frame layout with the RecognizerRunnerFragment, i am getting an error :

incompatible types: RecognizerRunnerFragment cannot be converted to Fragment

My code is as below : mRecognizerRunnerFragment = new RecognizerRunnerFragment(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.recognizer_runner_view_container, mRecognizerRunnerFragment); fragmentTransaction.commit();

Please help fix this.

Thanks, Samir

samirpramanik commented 3 years ago

Hi, any update?

mparadina commented 3 years ago

Hi @samirpramanik

Apologies for the delay in our response.

With BlinkCard 2.0.0, we've migrated to AndroidX fragments.

In your application, you would need to use the androidx.appcompat:appcompat library. Also, your Activity will need to extend the AppCompatActivity, which will give you access to the getSupportFragmentManager(), which needs to be replaced with the getFragmentManager(). It will also return androidx.fragment.app.FragmentTransaction​.

The sample code would be:

     mScanOverlay = createOverlay();
        if (null == savedInstanceState) {
            mRecognizerRunnerFragment = new RecognizerRunnerFragment();
            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            fragmentTransaction.replace(R.id.recognizer_runner_view_container, mRecognizerRunnerFragment);
            fragmentTransaction.commit();
        } else {
            mRecognizerRunnerFragment = (RecognizerRunnerFragment) getSupportFragmentManager().findFragmentById(R.id.recognizer_runner_view_container);
        }
    }

Also to note, this will also be written in the documentation after we've updated it.

Hope this helps.

Regards, Milan