Starting the GEO URI intent

bluedude

Well-Known Member
Licensed User
Longtime User
Had no luck in running it with the following code:

mapIntent.Initialize(mapIntent.ACTION_VIEW , "geo:")
mapIntent.Putextra("latitude",mapSettings.Get("latitude"))
mapIntent.Putextra("longitude",mapSettings.Get("longitude"))
StartActivity(mapIntent)

Any suggestions?
 

alfcen

Well-Known Member
Licensed User
Longtime User
Out of pure curiosity, what are you trying to accomplish?
I can't see any Map Intent in the current version of B4A.

If there is one, you have a space in lo ngitude and lat itude.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Intent

The space is just a paste mistake :)

I'm just trying to open the default geo URI supported by all most recent Android devices. This is to open Android Google maps.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I'm not very good with Intents but I think you need to pass a URI containing the request, not as extras. See the "geo:" entry here Intents List: Invoking Google Applications on Android Devices | Android Developers

Maybe like this - but I haven't tried it!
B4X:
latitude = 45.5
longitude = -5.5
geouri = "geo:" + latitude +"," + longitude
mapIntent.Initialize(mapIntent.ACTION_VIEW , geouri)
StartActivity(mapIntent)
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Geo

Think I tried that but will check it again.

Thanks! Also thanks for all your other great work :)
 
Upvote 0

StepWalk

Member
Licensed User
Longtime User
Had no luck in running it with the following code:

mapIntent.Initialize(mapIntent.ACTION_VIEW , "geo:")
mapIntent.Putextra("latitude",mapSettings.Get("latitude"))
mapIntent.Putextra("longitude",mapSettings.Get("longitude"))
StartActivity(mapIntent)

Any suggestions?

Try the following code snippet:



Dim Intent1 as Intent"
lat="40.56789"
lon="8.98765"
URI= "geo:" & lat & "," & lon & "?q=" & lat & "," & lon

Intent1.Initialize(Intent1.ACTION_VIEW,URI)
Intent1.SetComponent("googlemaps")
StartActivity(Intent1)




That works great on my mobile (Galaxy I9000) - and I took me quite some time to figure out how tell googlemaps not to show only a centered view of your lat,lon coordinates but also a marker at the lat,lon position. It's the "?q=" part, which repeats the coordinates as query. That way you'll see the wanted map with a marker at the correct position. Ohh ... don't know where those above coordinates are actually located - hopfully not in the middle of nowhere.:)
 
Upvote 0

ZJP

Active Member
Licensed User
Longtime User
@StepWalk
This is very interesting. Is it possible to have the complete listing? :sign0104:

JP
 
Upvote 0

alfcen

Well-Known Member
Licensed User
Longtime User
If coordinates are unavailable you can query by location name:

B4X:
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW,"geo:0,0?q="andorra")
Intent1.SetComponent("googlemaps")
StartActivity(Intent1)
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Alfcen, your code got extra quotation mark ( " ) :D
The right code is:
Intent1.Initialize(Intent1.ACTION_VIEW,"geo:0,0?q=andorra")
 
Upvote 0

StepWalk

Member
Licensed User
Longtime User
@StepWalk
This is very interesting. Is it possible to have the complete listing? :sign0104:

JP

That is the complete code - at least regarding the GoogleMaps handling. Put it in some activity and there you go. My snippet is part of some "work in progress". The scoope of it is an app which receives incoming sms messages with GPS coordinates coming from some nifty little GPS tracker modul. The app should extract the coordinates and forward them to GoogleMaps - showing where is someones dog, cat, car or wife :) right now. So far so good... What I need to accomplish that job is a working background activity a so called "service" which is not supported yet by B4A. But it's coming soon - says Erel. So for the present I focussed my activities at the GoogleMaps part and I got it running.
 
Upvote 0

ZJP

Active Member
Licensed User
Longtime User
I tried this with success ;)

B4X:
Sub Activity_Create(FirstTime As Boolean)

   Dim Intent1 As Intent
   Dim Intent2 As Intent

   lat="48.858082"
   lon="2.294649"

   URI= "geo:" & lat & "," & lon & "?z=18"

   Intent1.Initialize(Intent1.ACTION_VIEW,URI)
   Intent2.Initialize(Intent2.ACTION_CALL,"tel:1234567890")

   Intent1.SetComponent("googlemaps")
   Intent2.SetComponent("Dialer")

   StartActivity(Intent1)
   StartActivity(Intent2)

End Sub

You must add this line in the manifest file and make it readonly : <uses-permission android:name="android.permission.CALL_PHONE" />

B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="zjp.b4a.test01"
   android:versionCode="1"
   android:versionName=""
   android:installLocation="preferExternal">
   <uses-sdk android:minSdkVersion="4" />
   <uses-permission android:name="android.permission.CALL_PHONE" />
   <supports-screens
      android:largeScreens="true"
      android:normalScreens="true"
      android:smallScreens="true"
      android:anyDensity="true"/>
    <application android:icon="@drawable/icon" android:label="MonTest">
      <activity android:name=".main"
         android:label="MonTest" android:screenOrientation="unspecified">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
    </application>
</manifest>

JP
 
Last edited:
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!

Nice thread, i can also use it in my apps. I have one question about it:

Like your sms tracker, stepwalk, I want to show tracking-data from a server in the map. So when services are possible under b4a, the gps-data could send perhaps every second to google maps. But is it then possible to show the new position without opening google maps again? I mean, that you can see the tracking in the map updating every second? Or can the data only send to google maps by opening the intent?


rgds
 
Upvote 0

StepWalk

Member
Licensed User
Longtime User
Should be no problem, schimanski. If you call some living application like GoogleMaps over its intent driven API, the Android environment doesn't launch it a second or third time - instead the API just executes the new command/parameters showing some updated view. There are applications out on the market doing exactly that job - but they are made using genuine Java code - something that I'm still trying to avoid That's why I'll rather keep on waiting for the B4A "services" support. Yeah, probably it's my ignorance :) .
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
...thanks for that information.

Until there are not supported services, I'm still working on the OSM-Tilemapviewer. Downloading the Tiles is much difficulty than I thought, but I think, that I am on a good way. I post the code, if it runs without problems....
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!!

I have tested something with the code above and it seems, that the line

B4X:
Intent1.SetComponent("googlemaps")

makes no different. Under Android 2.2 (HTC Desire), Android will show me a list of all installed apps, which supports the GEO Uri Intent.

For all, who are interested: I have installed an app named 'Locus' from the android-market. It is freeware and supports the GEO Uri Intent. It has a lot of more features than google maps. You can choose between several maps (osm, google, nokia etc.) and it is possible to download maps into an sql-table to use it offline...

Does someone knows other apps, which supports the GEO uri, specially with using offline maps? I think, that these applications in close with b4a-services let us make a major step forward....:cool:

thanks for help...
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!

I have found this:

Locus, WhereYouGo, SmartMaps &bull; View topic - [DEVELOPING] - showing points on app

It is a way to show own point in the freeware-app Locus. Is it perhaps a way to send data to locus, without starting the intent with 'startactivity'?

I have tested locus by sending geo-data from my own application with a service-modul. With the code from stepwalk, it runs, but with one problem: StartActivity(Intent..) set the application always to the startscreen. So when the user is in the settings-screen, the service breaks the users input and set the application to the startscreen. So it is not possible to send a stream of data to the app, every few seconds (I know, that this is not the typical imagination of a service-modul, but I have to to show a live-stream of gps-data in a map.) I'm looking for a way to send only the data, without starting the intent every time new.

I have tested the same with googlemaps, but it is only a lot of chaos on the screen....

thanks for help...
 
Upvote 0
Top