Opening choising GPS windows (how to open Mapping apps installed on your device using App Inventor)

I would have my app open android choising windows to let operator choice which one he want to open...
but i don't know how to do this..
the only thing i succed to do is to open one GPS app with Activity starter, passing app package...

I'd like my app open this:

The only way a developer can create a link to an installed app on your device using App Inventor Block is to use an intent or having access to the linked app api (for some apps). With App Inventor, this means use the Activity Starter. ActivityStarter might be used to open each of the apps you show as icons in your image, or, if you have the api, link to a Web version of the 'mapping' app. If you can write the required scripts to create the intents, your next step is to make a Screen like you posted using a Table layout filled with eight images (or buttons that load the image you want to associate with the app).

On a Windows PC, you can use Snip and Sketch to capture each image for the Buttons.

captureImages .
Capture the images, place a Table (2 rows, 4 columns) and an Image or Button to hold the image using the set Button.Image to Blocks.

Use the click event of the Image control or Button to link your ActivityStarter code and load the app.

Your problem is to discover the ActivityStarter script need to instantiate each of these apps using your App Inventor 2 app. Use the advice in Using the Activity Starter and the documentation ActivityStarter .

Starting a Built-in Android Application from your App Inventor App

Apps that come built in with the Android device can be invoked “explicitly” by using package names and class names, as above. They can also be started “implicitly” by specifying an Action, in which case the Android operating system can figure out which actual application to start. The information used to start an app is called an intent, and the process for determining which application to start is called intent resolution. You can find information about intents in the Android system documentation on intents and intent filters.

Some apps are designed to accept extra information when they are launched. For example, the Android Map activity can accept geographic information that specifies a location to display. You must consult the documentation for the particular app to learn what this extra information is and how to specify it. You can also find information on Android Common Intents for Google Android applications available on most devices.

Generally, you specify the information by setting the ActivityStarter's properties just before the you launch the other app with StartActivity. You can set these in App Inventor using the ActivityStarter properties DataType and DataURI. There is also an Extras property that takes a list of keys and values and specifies the property values for the corresponding keys. The particular values you have to set depend on the activity you want to launch.

Activities that can be launched for Apps you created with App Inventor include:

  • Starting another App Inventor for Android app. To do so, first find out the class of the other application by downloading the source code and using a file explorer or unzip utility to find a file named “youngandroidproject/project.properties”. The first line of the file will start with “main=” and be followed by the class name; for example, main=com.gmail.Bitdiddle.Ben.HelloPurr.Screen1 . (The first components indicate that it was created by Ben.Bitdiddle@gmail.com.) To make your ActivityStarter launch this application, set the following properties:
    • ActivityPackage to the class name, dropping the last component (for example, com.gmail.Bitdiddle.Ben.HelloPurr )
    • ActivityClass to the entire class name (for example, com.gmail.Bitdiddle.Ben.HelloPurr.Screen1 )

Be aware, it may not be possible to establish a link to each and every one of these 'mapping' apps using an ActivityStarter.

Congratulations, you already know how to link to one of the GPS apps using App Inventor code.

Good luck.

it might be possible using the deep link extension?

@vknow360 might be able to answer this question

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

I didn't really found what i want in the links you gave me..
but i found this which works well

       public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("google.navigation:q=sevenans?")
            );
            startActivity(intent);

the problem is that Uri.parse is not the same parameter that DataUri in AI !
is there a way to pass Uri.parse througt AI ?

If you look more thoroughly at the ActivityStarter links you would find information on Android Common Intents for Google Android applications available on most devices. The link is in the documentation and has some Google Map scripts.

Other Mapping scripts are at https://developers.google.com/maps/documentation/urls/android-intents . These examples show how to get your intent using Java. You have to 'convert' what is recommended to the App Inventor way of using intents. What you posted is how to use intents using Java.

The following should help:

Button 2 evokes ... a Google Street View 'map'
Button 3 evokes ... a Google Map at the indicated latitude,longitude
Button 4 evokes ... Google Navigate to the indicated latitude,longitude
Instead of google.navigation:q=37.7749,-122.419 which works in North America, change the DataUri to google.navigation:q=Paris. It will work in Europe but not NA (no roads across the Atlantic :frowning: ). Or, you could just include coordinates in Europe.

Try these examples out. Do they work for you?

Getting intent information to elicit Google's apps in not difficult. You will find it difficult or impossible for the other geo-maps you have. Maybe you will get lucky. Explore; let us know what you discover. :slight_smile:

Thank you SteveJG :+1:

i tried what you proposed and it works very well to open google map.
But the phone i use have no sim card so it has no data and i can't use map that's why i want to be able to use other apps.
but others apps map have different possibililties depending on the app that's why i want have possibility to choice...

but i don't reaaly understand why this works

and this doesn't

even if java code , this works as i want

Blockquote
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=sevenans?")
);
startActivity(intent);

because it seems according to your exemple that AI DataURI corresponds to Java UriParse

i'm sur to be very close to the solutionbut not enougth ! :smirk:

Probably not.
@jean-marc_Latour wants to show a list of map related apps.
Maybe this can help you:

Use google.navigation:q=sevenans in the Text Block to access Google Navigate. Do not use "google.navigation:q=sevenans?" Do not use the question mark symbol ( ? ), Remove the quotation marks and see what happens. Using what code is recommended should bring up directions to Sevenans, France using Google Navigate.

What code works in Java does not necessarily work with the ActivityStarter in App Inventor. You cannot duplicate Java code in App Inventor. Use code appropriate to AI2.

I do not understand why you can not use your device, you do have to have a WIFI connection because these mapping programs must have access to Google's map servers.

I have two tablets, neither tabket has a sim card. Both work with Google Map and Google Navigate when using the ActivityStarter. The older tablet (Android 4.2.2 responds slowly with StreetView while the 8.1 does not) Also I have an old cell phone that no longer has a data service contract that works . To use these mapping apps, the devices must have a WIFI connection so they can access the Google map tiles (or a data connection ... which you do not have available to you).
.

OK. Do you know you can make your own App Inventor map app using the Map component and a navigation app using the Navigate component? The map uses OpenStreetMap map tiles.

You can also make a map using your own map image without a data or a wifi connection. The location placement is not very accurate but you might want to do this Offline Flat Map Coordinate conversion - SteveJG

Of course you're right ! i'm so stupid !
it works fine like that !

For my app there is no wifi and no data...

I will have a look on it but my purpose here was to use ready to go apps...

So tou help me to solve my problem: I can now open choice window in order to choice the app i want to use.
Thanks a lot. :+1:

well finally i'm a little bit confused because as i said this works:


in an app with just a button to click on

but the same code here
image
where activity is launch after listview.afterpicking doesn't works...it returns :"Error 601 : No corresponding activity was fouund"

But it is the same code !!!

well, almost... see again what @SteveJG said

Taifun

1 Like

Oh sorry: i posted an old screnn copy
because i did lots of try...
in first app all those bloks work !

I got it !

In my app i have other procedure which use ActivityStarter1 where i define Package and Class...so here it try to lanch VIEW with those parameters...
Now i use an other ActivityStarter and it works well...