Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Latest commit

 

History

History

open_a_webpage_in_the_browser_application

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
id title brief article sdk
6578B301-90E8-F7CF-FB34-7D4C0F280422
Open a Webpage in the Browser Application
This recipe shows how to launch a web page in the built-in browser application.
title url
Invoking Google Applications on Android Devices

Recipe

  1. Create a new Xamarin.Android application. The project template will create a single activity named Activity1 (MainActivity.cs), which contains a button.
  2. From the button.Click handler in MainActivity.cs, create a Uri and an Intent.
intent.button.Click += delegate {
       var uri = Android.Net.Uri.Parse ("http://www.xamarin.com");
       var intent = new Intent (Intent.ActionView, uri);
       StartActivity (intent);
};

Calling StartActivity and passing it the Intent in the above code launches the browser app.

Additional Information

Each screen in an application is represented by an activity. Using asynchronous messages called intents, when created from a Uri, causes the system to load an activity that can handle the Uri scheme. In this recipe a Uri beginning with http:// loads an activity from the browser application to display the page.