Page 1 of 1

mobilePickPhoto help :(

Posted: Tue May 03, 2016 3:17 am
by Opaquer
Hey everyone!

Sorry to be posting so many questions here lately, I've been trying to get the last parts of my app finalised :(.

So, I've come across some weird behaviour (as far as I can tell) with mobilePickPhoto. Basically, what I have at the moment are some photos that are stored on a user's Dropbox. The app will let them look at the photo and hopefully edit it. So, when they go to this section of the app, it should download the photo from Dropbox for the user to review (done). Now, here's the code I'm using for a button that will let the user take a photo, add a photo from their gallery, view it or delete it (those last 2 are only if there's already a photo there).

Code: Select all

global TestEdit

on mouseUp
   put 0 into TestEdit["FireExtinguisherEdit"]
   if the environment is "mobile" then
      if the text of image "FireExtinguisherTestImage" is empty then
         put "Camera"&cr&"Gallery" into choices
      else
         put "Camera"&cr&"Gallery"&cr&"View photo"&cr&"Delete photo" into choices
      end if
      mobilePick choices, 1, "cancel"
      put the result into choice
      if choice is not 0 then
         if exists(image "MobilePhoto") then
            delete image "MobilePhoto"
         end if
         set the name of the templateimage to "MobilePhoto"
         set the visible of the templateimage to false
         if choice=1 then
            mobilePickPhoto "camera"
            if the result is not "cancel" then
               if the text of image "FireExtinguisherTestImage" is empty then
                  put image "MobilePhoto" into image "FireExtinguisherTestImage"
               else
                  set the text of image "FireExtinguisherTestImage" to the text of image "MobilePhoto"
               end if
               delete image "MobilePhoto"
               put 1 into TestEdit["FireExtinguisherEdit"]
               set the label of me to "Fire extinguisher test uploaded"
            end if
         else if choice=2 then
            mobilePickPhoto "library"
            if the result is not "cancel" then
               if the text of image "FireExtinguisherTestImage" is empty then
                  put image "MobilePhoto" into image "FireExtinguisherTestImage"
               else
                  set the text of image "FireExtinguisherTestImage" to the text of image "MobilePhoto"
               end if
               delete image "MobilePhoto"
               put 1 into TestEdit["FireExtinguisherEdit"]
               set the label of me to "Fire extinguisher test uploaded"
            end if
         else if choice=3 then
            lock the screen
            hide group "PolicyGroup"
            show group "PolicyImageGroup"
            put image "FireExtinguisherTestImage" into image "PolicyImage"
            unlock the screen
         else if choice=4 then
            set the text of image "FireExtinguisherTestImage" to empty
            set the label of me to "Upload fire extinguisher test"
         end if
      end if
   end if
end mouseUp
So, quick rundown: TestEdit is there so that I can tell if they've uploaded a new photo so it doesn't upload the same photo each time. The mobilePick works perfectly depending on if they've already got a photo to view. The issue comes when they want to add a photo from their camera. For some reason, when I put it on my phone to try (which, admittedly is an Android, but it's meant to be for iOS, and it's worked before), most of the time it will crash the app and reset it as if I had just opened it... But, not always, which is the weird thing. Also sometimes it works from the start, sometimes it doesn't work if it downloads a picture from Dropbox, and sometimes it just doesn't work at all :(

EDIT: Also, I forgot to mention, I ran it again with answer 1, answer 2, answer 3 etc at every line basically to see where it fails. I had this:

Code: Select all

            answer 3
            mobilePickPhoto "camera"
            answer 4
And it answered 3, gave me the option to take a photo, and then didn't answer 4 and crashed :(. So there's probably an issue there, but I don't understand what it could be :(

Is it a coding issue, is it an issue with Livecode, or did I just do a stupid and can't figure out how this works?

Edit 2: I restarted my computer, checked every variable, restarted my phone, built my app as a standalone for the 10th time, re-re-re-re-re-re-re-re-installed it on my phone and tried again. It seems to be fixed for now, so perhaps I was just tired and didn't go through all the steps to make sure, but for now it's fixed :)

Thanks in advanced

Michael