FLIR One Developer / Blog / Topics / FLIRONEExampleApplication always fails to start

FLIRONEExampleApplication always fails to start

Home Forums FLIR ONE SDK Development Device specific CAT S60/S61 smartphones FLIRONEExampleApplication always fails to start

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of George George 1 year, 8 months ago.

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

  • Author

    Posts

  • #5209

    Profile photo of George
    George

    Participant

    Hi,

    I downloaded and extracted the 1.2.8 version of the SDK and imported the FLIRONEExampleApplication into Android Studio v2.3.1. I followed the instructions carefully and everything that is said is that this example app is the best place to start. I am using this on the CAT S60 device.

    I run it the PreviewActivity and it doesn’t work. I keep getting this error

    04-11 22:53:53.654 22330-22330/com.flir.flironeexampleapplication E/AndroidRuntime: [ERB] Update app failure countmain
    04-11 22:53:53.654 22330-22330/com.flir.flironeexampleapplication E/AndroidRuntime: [ERB] Update app failure - ActivityThread.currentProcessName : com.flir.flironeexampleapplication
    04-11 22:53:53.654 22330-22330/com.flir.flironeexampleapplication E/AndroidRuntime: [ERB] Update app failure - Process.myPid : 22330
                                                                                        
                                                                                        --------- beginning of crash
    04-11 22:53:53.655 22330-22330/com.flir.flironeexampleapplication E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                        Process: com.flir.flironeexampleapplication, PID: 22330
                                                                                        java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity
                                                                                            at com.flir.flironesdk.EmbeddedDevice$VisibleCameraModule$1.run(EmbeddedDevice.java:213)
                                                                                            at android.os.Handler.handleCallback(Handler.java:739)
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                            at android.os.Looper.loop(Looper.java:148)
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

    #5218

    Profile photo of George
    George

    Participant

    Right, so I don’t get why the samples app can’t be updated or even update the docs.

    The biggest misconception in the developer docs is the below

    ### Differences with Cat® S60
    When running on the Cat® S60, the SDK will not connect to a FLIR One when using Device.startDiscovery. The SDK also opens the visible camera for you, asking the user for permission if needed. Your app may need to stop and start the frame stream in your activity’s onRequestPermissionsResult so that the visible camera gets started.

    In fact it the SDK does not ask the user permission if needed. You need to do this manually. Also you still need to run the Device.startDiscovery code so that you get an instance of the flir device. I also found it oddly worded saying that “the sdk also opens the visible camera for you” it should mean that when your onDeviceConnected() method is activated, in there you can called device.startFrameStream(this) which will open the thermal camera for you. And when it does that it does not ask for permissions, this is the trick where you should have requested them before.

    Something like this can check if you have camera permissions

    private boolean hasCameraPermission() {
      int perm = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
      return PackageManager.PERMISSION_GRANTED == perm;
    }

    Then you can request permission from the user
    ActivityCompat.requestPermissions(this, Manifest.permission.CAMERA, 20);

    And of course you’d have to implement the request permission call back that you can find tutorials all over the net on how to do that one.

    #5307

    Profile photo of MARCOS
    MARCOS

    Participant

    Hey George,
    I’m developing an Thermal app with CAT S60 Thermal Cam.
    Did you solved you issue?. My app didn’t work yet, because of it:

    FATAL EXCEPTION: main
    Process: com.manco.thermal.flirdemothermal, PID: 27327
    java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity
    at com.flir.flironesdk.EmbeddedDevice$VisibleCameraModule$1.run(EmbeddedDevice.java:213)

    I add this example for permission request:
    https://github.com/george-haddad/thermic/
    The FullscreenActivity.java is calling the abstract method onPermissionsGranted in RuntimePermissionsActivity abstract class


    @Override
    public void onPermissionsGranted(int requestCode) {
    Toast.makeText(this, “Permissions Received.”, Toast.LENGTH_LONG).show();
    if(hasCameraPermission()) {
    Device.startDiscovery(this, this);
    if(flirDevice != null) {
    flirDevice.startFrameStream(this);
    }
    }
    }/
    private boolean hasCameraPermission() {
    int perm = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    return PackageManager.PERMISSION_GRANTED == perm;
    }

    • This reply was modified 3 years, 4 months ago by Profile photo of MARCOS MARCOS.
    • This reply was modified 3 years, 4 months ago by Profile photo of MARCOS MARCOS.

    #5310

    Profile photo of George
    George

    Participant

    Yes I did solve it and posted the code up on github as you already have the link. The problem was that you need to grant permissions to the app to use the camera. And granting the permissions in the new android way which is on demand.

    When I run my example app it asks for 2 permissions and I grant them, after a few seconds it starts reading the frames from the camera.

    #8173

    Profile photo of George
    George

    Participant

    I’ve updated the thermic repo which should run better and show examples of how to capture images and save them to the phone.

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

You must be logged in to reply to this topic.