1

I am trying to add a podcast and a youtube channel to my native Android app, but it seems it would be much easier if I just use HTML and access that media as it is on the web.

Is it possible to have an activity be HTML5 or a basic web view? If so, how can I do that?

Thanks!

Genadinik
  • 18,153
  • 63
  • 185
  • 284
  • 1
    Yes, have a look into WebView: http://developer.android.com/reference/android/webkit/WebView.html – Ken Wolf Jul 04 '13 at 15:47
  • @KenWolf Thank you Ken, and do you think I am correct in trying to accomplish this via a WebView? Or should I have done it natively? It shouldn't matter too much, right? – Genadinik Jul 04 '13 at 15:52
  • Well, the WebView solution would be the easiest - however there may be performance and compatability issues on older Android platforms (how is your podcast embedded, flash support, etc.). Not all HTML5 tags are supported. Check the site on a native browser, is that good enough for you? I would try the easy solution first, you can always complicate it later :) – Ken Wolf Jul 04 '13 at 15:57
  • @KenWolf Thanks, you bring up a lot of interesting points. I think the podcast is a typical iTunes podcast. And also for videos, I would basically just import a YouTube channel Do you think that should cause a problem? – Genadinik Jul 04 '13 at 16:02
  • @KenWolf also on the link you sent, it says that it is part of Android api level 17. Would you know what is the earliest api level that supported WebView? Thanks! – Genadinik Jul 04 '13 at 16:16
  • WebView has been around since level 1 "Added in API level 1" top right. I can't really say whether it would cause a problem or not. I believe a native solution will be better. But will cost more. If you want me to spec it for you that's a different conversaion. :) – Ken Wolf Jul 04 '13 at 16:22
  • @KenWolf I just got it to work with a WebView - pretty simple. Thank you! Last question: it looks like it opened an browser. Is this still considered as "being inside my app" or did it actually put my app in the background and simply called the phone's browser? – Genadinik Jul 04 '13 at 16:33
  • You must have clicked something or maybe your site has redirects. Either way, to handle all clicks you need to implement a custom WebViewClient. See here: http://stackoverflow.com/questions/2378800/clicking-urls-opens-default-browser – Ken Wolf Jul 04 '13 at 16:44

1 Answers1

1

Yes this is possible, have a look into WebView

http://developer.android.com/reference/android/webkit/WebView.html

A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

You may find some performance/compatability issues but this is the easiest solution and one that I would do as a first step.

Ken Wolf
  • 23,133
  • 6
  • 63
  • 84