Browsing by Intent
The simplest thing you can do with Android’s networking API is to open a browser on a web page of your choice. You might want to do this to provide a link to your home page from your program or to access some server-based application such as an ordering system. In Android all it takes is three lines of code plus a bit of setup.
To demonstrate, let’s write a new example called BrowserIntent, which will have an edit field where you can enter a URL and a Go button you press to open the browser on that URL (see the figure). Start by creating a new “Hello, Android” project with the following values in the New Project wizard:
| Application name: BrowserIntent |
| Company Domain: example.org |
| Form factors: Phone and Tablet |
| Minimum ... |
Get Hello, Android, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.