concept ActivityStarter in category python

appears as: ActivityStarter, ActivityStarter
Hello App Inventor!: Android programming for kids and the rest of us

This is an excerpt from Manning's book Hello App Inventor!: Android programming for kids and the rest of us.

As we mentioned earlier, the barcode contains some information that could be genuinely useful to you. For example, if you have the barcode of a book and want to find out how much it costs or where you can buy it, the key is, of course, the internet! The barcode on a book relates directly to the ISBN number, which uniquely identifies that book. By scanning the barcode and launching a search engine (like Google or Yahoo!), you can go straight to a website that contains information about the book. It works for other products too: pizza, salad, lemonade, ice cream ... (it must be lunchtime!). In order to launch the internet browser from App Inventor, you need to use a component that’s new to you: the ActivityStarter component.

Learning Point: What is the ActivityStarter component?

We have a phrase in Britain (which comes from an advertising campaign for paint): “It does what it says on the tin.” This is just such an example. The ActivityStarter component ... starts activities. If you want to start another app from within your app, you have to find out the package and class name (a way of organizing code in Java) and set the properties of the component to match. This could include searching the web for something, going to a particular web page, opening a map on Google Earth, starting someone else’s app from in your app ... almost anything a smartphone can do.

3.  Add a Button, an ActivityStarter (from the Connectivity Palette group), and a Notifier (from the User Interface Palette group).

4.  Set the ActivityStarter properties as shown next.

To activate the ActivityStarter, you use the block call ActivityStarter1.StartActivity. You could do that from the OpenBrowserButton.Click event, like this.

From this sequence, you can work out that the Button.Click event opens the Notifier, and then the Notifier.AfterChoosing event triggers the ActivityStarter. Here are the blocks:

Your app should now launch a web browser successfully—give it a try. ActivityStarter is versatile and can launch other apps such as the camera, Google Maps, and even other apps you’ve written. Also, if you enter a URL to a specific resource related to an app, Android will present more options in the app list. For example, if you have the YouTube app installed and you use a YouTube URL, then you’ll have the option to view the video in your browser or YouTube app. There’s full documentation about how to do this on MIT’s App Inventor website here: http://mng.bz/0x89.

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest