September 1, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Fine-Tune Web Apps and Websites for Android, Page 2

  • September 6, 2011
  • By Lauren Darcey & Shane Conder
  • Send Email »
  • More Articles »

Which Browsers Are Available on Android Devices?

Most users will stick to the default Browser application that comes installed on the device. However, manufacturers and mobile carriers sometimes modify the browsers installed. Also, some users will install third party browsers on their devices.

The performance characteristics and features available on these alternative browsers vary. Some popular third party browsers available today include:

Fine-Tune Web Apps and Websites for Android

Whether you have an existing Web application or are considering developing one that Android users might be interested in, you'll want to start by trying to load it up on an Android device and seeing how it performs. Most of the changes you might require will be obvious once you start poking around. You'll also want to check out the Web Apps Development Guide available on the Android developer website, which can give you some Android-specific tips and tricks as well.

While some methods of producing Web applications ignore screen size or allow the user to size content as they see fit, some Web application developers will still be concerned with how graphics look and getting images and text to look good. There are several techniques that can be used from the JavaScript and CSS to make images and text to look as best as possible. Depending on whether the Web application is running in a WebView or not, and what other sorts of compatibility layers may be in place, the method you choose will vary. Some options include using the viewport meta tag in the head of your Web document, targeting images to specific densities using CSS or JavaScript. These techniques are discussed in further detail in "Targeting Screens from Web Apps."

Write Web-Enabled Native Applications Using WebView?

If you want to develop a native application that loads and displays Web content, then you'll need to learn how to develop Android applications using Java and the Android SDK. You can begin by downloading and installing the latest Android SDK and tools from the Android developer website.

Once you have designed your application, you'll use WebView controls within your layout files to display Web content, be it locally sourced or on the network. You can then create JavaScript interfaces, written in Java, to provide the "glue" between your Web content and the native Android Java application. You could, for example, create a website with a button that triggers the device to launch the Camera using the appropriate Android APIs. Keep in mind that when you start opening up the device by adding JavaScript interfaces, you are making the device more vulnerable to exploitation.

The WebView control is quite configurable. By default, it renders simple Web content, but all bells and whistles are disabled. You can enable Web settings like JavaScript, plug-ins, zoom controls, and more. You can react to user events like key events, touch events, trackball events and focus changes. You can enable or disable secure or private browsing. You can have a single window or multiple windows. There are numerous other settings. You'll want to begin by looking at the WebView class (android.webkit.WebView) as well as the WebSettings class (android.webkit.WebSettings). If you're building a Fragment-aware application, you'll also want to look at the WebViewFragment class (android.webkit.WebViewFragment).

Want some information about Browser application searches and bookmarks? Use the Browser content provider.

Web Application Frameworks Can Help

If you want access to native SDK components, but don't want to spend the time writing the interfaces yourself (or maybe you don't have time or resources to learn Android for a simple project), open source projects like PhoneGap can help provide this functionality. This is especially useful when you want to develop cross-platform Web applications

Conclusion

Android users can consume Web content through the Android device Browser application or from within a special native control called WebView that can be embedded within a native Android application written in Java. There are many ways to incorporate fresh Web content into your applications, or bring your existing Web applications to new mobile audiences like Android. As usual, we'd love to hear how you're considering using Web technologies in relation to the Android platform. Leave us a comment and tell us what you're up to!

About the Authors

Shane Conder Shane Conder and Lauren Darcey--Contributing Editors, Mobile Development--have coauthored two books on Android development: an in-depth programming book entitled Android Wireless Application Development (ISBN-13: 978-0-321-62709-4) and Sams Teach Yourself Android Application Development in 24 Hours (ISBN-13: 978-0-321-67335-0). When not writing, they spend their time developing mobile software at their company and providing consulting services.

        Email        |        Blog        |        Twitter

Lauren Darcey

Tags: Android, mobile web development

Originally published on http://www.developer.com.

Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel