Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo SDK Support › NativeDialog camera on Android

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #25576

    nks (baumemo)

    Hi Felgo Team,

    its me again^^ I’m sorry. I found an interesting bug. I used nativeUtils displayCameraPicker to take a photo. I replaced it with NativeDialog.camera to reduce boilerplate code.

    This seems to work on iOS but makes problems on android in my app. Can you check out the problem? Tested on Google Pixel 8 and Sony XPeria X compact. Both didn’t work.

    Here is some code.

    Before (we opened a extra page to take the photo, this works perfectly):

    import Felgo
    import QtQuick
    
    AppPage {
        id: currentPage
        title: qsTr("Kamera")
    
        Component.onCompleted: {
            nativeUtils.displayCameraPicker("Foto aufnehmen")
        }
    
        Connections {
            target: nativeUtils
            onCameraPickerFinished: {
                if(accepted)
                {
                    console.log("Foto aufgenommen");
                    logic.storeImage(path);
                }
                currentPage.navigationStack.pop();
            }
        }
    }

    New (this works not on android. Get called from click event handler):

    NativeDialog.camera((success, path) => {
        if(success)
        {
            logic.storeImage(path)
        }
    })

    Thanks for your support.

    #25577

    Günther
    Felgo Team

    Hi,

    thank you for the bug report. I added it to our Bug-Tracker so we can take a look and fix it for a future update.
    As the Camera implementation using NativeUtils still works as expected I suggest to use this one for now.

    Best,
    Günther

    #25587

    Alex
    Felgo Team

    Hi,

    We could not reproduce the issue, can you please give this snippet a try on your phone and let us know if you still experience the issue?

     

    import Felgo
    import QtQuick
    
    App {
      AppPage {
        AppButton {
          text: "Take photo"
          anchors.centerIn: parent
    
          onClicked: {
            NativeDialog.camera((accepted, path) => {
              console.warn("Photo:", accepted, path);
            })
          }
        }
      }
    }

     

    Thanks,

    Alex from Felgo

    #25595

    nks (baumemo)

    Hi Alex,

    first of all sorry for my late answer. I haven’t visited the forum for a while.

    So the problem seems to be special to our app. We changed our MainAndroidActivity (see https://felgo.com/developers/forums/t/adaptive-icon-splash-screen-best-practice-android).

    We changed the activity in the manifest from com.felgo.helper.FelgoActivity to a custom implementation:

    ...
        <application android:hardwareAccelerated="true" android:name="com.felgo.helper.FelgoApplication" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:allowNativeHeapPointerTagging="false" android:extractNativeLibs="true">
            <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="de.my.app.MyActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTop" android:exported="true">
    ...

     

    I created a java file containing this:

    ...
    public class MyActivity extends QtActivity
    ...

     

    When doing so the problem occurs. Any hint what is the problem here?

     

    #25600

    Alex
    Felgo Team

    Hi,

    You would need to make the base class of your custom MyActivity to be FelgoActivity, instead of QtActivity, and make sure to call all “super function” in your custom implementation.

    Best,

    Alex from Felgo

    #25601

    nks (baumemo)

    Thanks Alex. This was the mistake I did. Your post helped me a lot.

Viewing 6 posts - 1 through 6 (of 6 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded