mobile browser android (resolved)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

mobile browser android (resolved)

Post by vedus » Sat Mar 08, 2014 3:09 am

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
Last edited by vedus on Sat Mar 08, 2014 3:53 pm, edited 1 time in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobile browser

Post by Simon » Sat Mar 08, 2014 3:56 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobile browser

Post by vedus » Sat Mar 08, 2014 1:12 pm

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.
Attachments
findme.zip
(40.1 KiB) Downloaded 185 times

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobile browser

Post by Klaus » Sat Mar 08, 2014 1:38 pm

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

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobile browser

Post by vedus » Sat Mar 08, 2014 1:52 pm

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 :)

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobile browser

Post by vedus » Sat Mar 08, 2014 2:03 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobile browser

Post by Klaus » Sat Mar 08, 2014 2:31 pm

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.

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobile browser

Post by vedus » Sat Mar 08, 2014 3:53 pm

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

Post Reply