Displaying a web page in your application
When you want to display HTML content on a web page, you have two choices: call the default browser or display them within your app. If you just want to call the default browser, use an Intent as follows:
Uri uri = Uri.parse("https://www.packtpub.com/"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
If you need to display the content within your own application, you can use the WebView
. This recipe will show how to display a web page in your application, as can be seen in this screenshot:
Getting ready
Create a new project in Android Studio and call it WebView
. Use the default ...
Get Android Application Development Cookbook - Second 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.