Page 1 of 1

mobile browser android (resolved)

Posted: Sat Mar 08, 2014 3:09 am
by vedus
i am try to reproduce this code from dixie but still i can't figure out what i do wrong.
in the emulator and the phone i get the error "webpage is no available"
here is the code i use and the photos with info bellow..
in app settings ,internet and locations is checked and file included in the copy.(internet i have :D )

Code: Select all

global sBrowserid

# when the card is opened make sure that default settings are configured
on preOpenCard
      # quit if we are not on a mobile device
      if the environment is not "mobile" then exit preOpenCard
  if  mobileCanTrackLocation() then
          mobileStartTrackingLocation     -- Will fire locationChanged when GPS is found
     else
          Answer "This mobile is NOT able to track GPS location"
      end if
  
end preOpenCard

/////

on opencard
  if the environment is not "mobile" then exit OpenCard
  
  put specialFolderPath("documents") & "/lcNav.html" into thehtmlFile
  
     /* change the latitude & longditude in the html file to display the chosen city */
     put URL("file:" & thehtmlFile) into theData
     put "var myLatlng = new google.maps.LatLng(" & fld "f3" of card "showrecords" & ");" into line 16 of theData
  
     put theData into URL ("file:" & thehtmlFile)
    // answer theData
  
     put "file://" & specialFolderPath("documents") & "/lcNav.html" into theURL
     replace space with "%20" in theURL
  
  answer theURL
  

   gotourl
  
end opencard

on gotourl
   # create the browser  
     mobileControlCreate "browser"
      put the result into sBrowserId
      # set up the basic defaults
      mobileControlSet sBrowserId, "rect", the rect of group "Browser"
      mobileControlSet sBrowserId, "visible", "true"
   mobileControlSet sBrowserid, "url", theURL
end gotourl

  # destroy the browser we created 
on closeCard
         mobileControlDelete sBrowserId
end closeCard
any help will be nice!!!
Screen Shot 2014-03-08 at 4.03.57 AM.png
Screen Shot 2014-03-08 at 4.06.07 AM.png
Screen Shot 2014-03-08 at 4.06.19 AM.png

Re: mobile browser

Posted: Sat Mar 08, 2014 3:56 am
by Simon
I see one error
put specialFolderPath("documents") & "/lcNav.html" into thehtmlFile
should be
put specialFolderPath("engine") & "/lcNav.html" into thehtmlFile

You may have to copy the file from the engine to documents (not sure if you have to).
put url("file:" & specialFolderPath("engine") & "/lcNav.html") into url("file:" & specialFolderPath("documents") & "/lcNav.html")
then you above code will work.

Simon

Re: mobile browser

Posted: Sat Mar 08, 2014 1:12 pm
by vedus
hi simon thank you for your time ;)
i have change the code but now i get empty screen.i have make a text fld to reproduce the html code,from the file and still i don't see any error:(
i like the browser is not triggering.
when i open the lcNav2.html page in mac (safari)the maps showing up ok
here is the new code

Code: Select all

lobal browserID
# when the card is opened make sure that default settings are configured
on preOpenCard
      # quit if we are not on a mobile device
      if the environment is not "mobile" then exit preOpenCard
  if  mobileCanTrackLocation() then
          mobileStartTrackingLocation     -- Will fire locationChanged when GPS is found
     else
          Answer "This mobile is NOT able to track GPS location"
      end if
end preOpenCard

/////

on opencard
  if the environment is not "mobile" then exit OpenCard
  #test
  
  put specialFolderPath("documents") & "/lcNav2.html" into documentFilePath
     if there is not a file documentFilePath then
          put specialFolderPath("engine") & "/lcNav2.html" into engineFilePath
          put URL ("binfile:" & engineFilePath) into URL ("binfile:" & documentFilePath)
     end if
  
  
    put specialFolderPath("documents") & "/lcNav2.html" into thehtmlFile
        put URL("file:" & thehtmlFile) into theData
        put "var myLatlng = new google.maps.LatLng(" & fld "f3" of card "showrecords" & ");" into line 15 of theData
        put theData into URL ("file:" & thehtmlFile)
        put "file://" & specialFolderPath("documents") & "/lcNav2.html" into theURL
        replace space with "%20" in theURL
  put theData into fld "test" of cd "test_html"
  
 ///// end test 
     gotourl
  
end opencard

on gotourl
   # create the browser  
      # set up the basic defaults
   mobileControlCreate "browser"
     put the result into browserID
     mobileControlSet browserID, "visible", "true"
     mobileControlSet browserID, "url", theURL
end gotourl

  # destroy the browser we created 
on closeCard
         mobileControlDelete browserID
end closeCard
i have incude the file in zip if anyone want to see it.

Re: mobile browser

Posted: Sat Mar 08, 2014 1:38 pm
by Klaus
Hi vedus,

you need to also declare theURL as LOCAL (and not LOBAL! 8) ), so the other handlers can use it!
...
local browserID
local theURL
## The rest should work now...
...

Best

Klaus

Re: mobile browser

Posted: Sat Mar 08, 2014 1:52 pm
by vedus
Klaus wrote:Hi vedus,

you need to also declare theURL as LOCAL (and not LOBAL! 8) ), so the other handlers can use it!
...
local browserID
local theURL
## The rest should work now...
...

Best

Klaus
Give me a min i will test it :)

Re: mobile browser

Posted: Sat Mar 08, 2014 2:03 pm
by vedus
Klaus i get the same results....
empty screen :(
i have declare as local both i check the code again and still on simulator and phone empty..
btw i have test all phone api's in simulator still the same

Re: mobile browser

Posted: Sat Mar 08, 2014 2:31 pm
by Klaus
Hmm, have to guess...
You are copying the HTML files a BINFILE, but then read in as TEXT, maybe that is causing problem?

Try this:
...
put specialFolderPath("documents") & "/lcNav2.html" into thehtmlFile
##put URL("file:" & thehtmlFile) into theData
put URL("binfile:" & thehtmlFile) into theData
...
At least worth a try.

Re: mobile browser

Posted: Sat Mar 08, 2014 3:53 pm
by vedus
final i fixed with the help from the simon and Klaus.
here is the final code if anyone need it.
and here is the development video for the maps(Problems and solutions for show up maps) i am sure someone will be need it.
https://www.youtube.com/watch?v=21PDd17dnnI#t=925

Code: Select all

local browserID
local theURL
# when the card is opened make sure that default settings are configured
on preOpenCard
      # quit if we are not on a mobile device
      if the environment is not "mobile" then exit preOpenCard
  if  mobileCanTrackLocation() then
          mobileStartTrackingLocation     -- Will fire locationChanged when GPS is found
     else
          Answer "This mobile is NOT able to track GPS location"
      end if
end preOpenCard

/////

on opencard
  if the environment is not "mobile" then exit OpenCard
  #test
  put specialFolderPath("documents") & "/lcNav2.html" into documentFilePath
     if there is not a file documentFilePath then
          put specialFolderPath("engine") & "/lcNav2.html" into engineFilePath
          put URL ("binfile:" & engineFilePath) into URL ("binfile:" & documentFilePath)
     end if

    put specialFolderPath("documents") & "/lcNav2.html" into thehtmlFile
        put URL("file:" & thehtmlFile) into theData
        put "var myLatlng = new google.maps.LatLng(" & fld "f3" of card "showrecords" & ");" into line 15 of theData
put "zoom:17," into line 17 of theData # < change the zoom factor to 50meters
        put theData into URL ("file:" & thehtmlFile)
        put "file://" & specialFolderPath("documents") & "/lcNav2.html" into theURL
        replace space with "%20" in theURL
  put theData into fld "test" of cd "test_html"
  
///// end test 
   # create the browser  
 mobileControlCreate "browser"
     put the result into browserID
      # set up the basic defaults
  mobileControlSet browserID, "rect", the rect of group "Browser"
     mobileControlSet browserID, "visible", "true"
     mobileControlSet browserID, "url", theURL
  
end opencard

  # destroy the browser we created 
on closeCard
         mobileControlDelete browserID
end closeCard