Question

I'm not exactly sure how to state this but here's the basic idea of what I'm trying to do:

I'm making a radio player application in Android Java. The function I'm looking at including is a dynamic TextView that get's the title of the song that's currently playing from either the website or ShoutCast.

My thoughts as they stand now is that my XML can stay as it is (a "content_wrap"-ed @string value). I just have no idea if there's a way to change that XML from Java and how to get the HTML (I'm not even sure if I need to use HTML) from the website.

Thank you in advance. You are all great people for even reading this :)

Was it helpful?

Solution

To answer my own question (regarding what I was looking for). I believe what I was starting with was javascript (something like a webplayer that constantly updated, so the title wasn't actually in the code nor the redirection).

What I did was from a permanent list (a played list in my case) and connect to that URL with a URLconnection (java.net.URL & java.net.URLConnection) then use a BufferedReader (java.io.BufferedReader). This part can probably be optomized more using the BufferedReader's mark and restart methods, but for this one I just kept circling though until I found a permanent mark then trimmed it till I found what I needed.

e.g.

while (!br.contains("PERMANANT MARK BEFORE MY DESIRED INFO"))
      br.readLine(); //Which advances the line
String s = br.readLine(); //Repeat this till you get your info into s
//Trim functions (I used the </td> to my advantage)
s = s.split("THING NEXT TO INFO")[0[;
display.setText(s);

Thank you to everyone who read this. Good luck on your endeavors!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top