I am new to Java/my IDE, eclipse. I am alright at C and most often
program arduino, making debugging simply sending a Serial command of a
var's value. I tried debugging the best I know how, but couldn't
figure out where it was going wrong.

On Dec 19, 3:49 am, Zsolt Vasvari <[email protected]> wrote:
> Are you new to development in general?  If not, I am sure you have
> debugged code before, so do that.
>
> On Dec 19, 3:23 pm, Taylor Niver <[email protected]> wrote:
>
>
>
>
>
>
>
> > I'm new to android development and am trying to start learning the
> > basics by decoding a RSS feed. I want to store the appropriate info
> > (title, link, etc) into
> > the appropriate corresponding strings. I have the below, which will
> > search for anything that starts with <t (for title), and store the
> > corresponding values into a char array. I then search for the end
> > bracket ('</") and stop storing the information. I then convert the
> > char array into a string, and toast the string when I press button 1.
> > My problem is, when I press the button, it toasts a blank box, meaning
> > that the string is empty. Does anyone have any idea on how to fix
> > this? Thanks!
>
> > My Code:
>
> > package rssread.withoutinernet;
>
> > import android.app.Activity;
> > import android.os.Bundle;
>
> > import android.view.View;
> > import android.widget.Button;
> > import android.widget.Toast;
>
> > public class RssReaderNoInternetActivity extends Activity {
>
> >         Button button1;
> >         Button button2;
> >         Button button3;
> >         String RSS_String = "<?xml version='1.0' encoding='UTF-8'?><rss
> > xmlns:atom='http://www.w3.org/2005/Atom'xmlns:openSearch='http://
> > a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/
> > georss' xmlns:thr='http://purl.org/syndication/thread/1.0'
> > version='2.0'>"
> >                         + 
> > "<channel><atom:id>tag:blogger.com,1999:blog-7784086607297621793</
> > atom:id><lastBuildDate>Thu, 01 Dec 2011 20:42:16 +0000</
> > lastBuildDate><title>Bird's eye view</title>"
> >                         + 
> > "<description></description><link>http://blogname.blogspot.com/</
> > link><managingEditor>[email protected] (blonde ambition)</
> > managingEditor>"
> >                         + 
> > "<generator>Blogger</generator><openSearch:totalResults>0</
> > openSearch:totalResults><openSearch:startIndex>1</
> > openSearch:startIndex><openSearch:itemsPerPage>25</
> > openSearch:itemsPerPage></channel></rss>";
>
> >         int counter = 0;
> >         int title_counter = 0;
> >         int bounce;
>
> >         char[] rss = RSS_String.toCharArray();
>
> >         char[] title;
>
> >         String Title_String;
>
> >         @Override
> >         public void onCreate(Bundle savedInstanceState) {
> >                 super.onCreate(savedInstanceState);
> >                 setContentView(R.layout.main);
>
> >                 RSSDecode();
> >                 test();
> >                 Listeners();
>
> >         }
>
> >         public void Listeners() {
> >                 // Title
> >                 button1 = (Button) findViewById(R.id.button1);
> >                 button1.setOnClickListener(new View.OnClickListener() {
> >                         public void onClick(View v) {
> >                                 Toast.makeText(getApplicationContext(), 
> > RSS_String,
> > Toast.LENGTH_SHORT).show();
> >                         }
> >                 });
>
> >                 // Description
> >                 button2 = (Button) findViewById(R.id.button2);
> >                 button2.setOnClickListener(new View.OnClickListener() {
> >                         public void onClick(View v) {
> >                                 Toast.makeText(getApplicationContext(), 
> > Title_String,
> > Toast.LENGTH_SHORT).show();
> >                         }
> >                 });
>
> >                 // Link
> >                 button3 = (Button) findViewById(R.id.button3);
> >                 button3.setOnClickListener(new View.OnClickListener() {
> >                         public void onClick(View v) {
> >                                 Toast.makeText(getApplicationContext(), 
> > "Var3Goeshere",
> > Toast.LENGTH_SHORT).show();
> >                         }
> >                 });
>
> >         }
>
> >         public void test(){
> >                 title[1]= 'c';
> >                 title[2]= 'o';
> >                 Title_String = title.toString();
> >         }
>
> >         public void RSSDecode() {
> >                 try {
> >                         while (counter <= 500) {
> >                                 if (RSS_String.charAt(counter) == '<') {
> >                                         if (RSS_String.charAt(counter + 1) 
> > == 't') {
> >                                                 counter = counter + 8;
> >                                                 bounce = 0;
> >                                                 while (bounce == 0) {
>
> >                                                         // Test if its the 
> > end
> >                                                         if 
> > (RSS_String.charAt(counter) == '<') {
> >                                                                 if 
> > (RSS_String.charAt(counter + 1) == '/') {
> >                                                                         
> > bounce = 1;
> >                                                                 }
> >                                                         }
>
> >                                                         //Store values into 
> > char array and convert into string
> >                                                         
> > title[title_counter] = (RSS_String.charAt(counter));
> >                                                         counter = counter + 
> > 1;
> >                                                         title_counter = 
> > title_counter + 1;
>
> >                                                 }
>
> >                                         }
>
> >                                 }
>
> >                                 Title_String = title.toString();
> >                                 counter = counter + 1;
>
> >                         }
> >                 } catch (Exception e) {
> >                         Toast.makeText(getApplicationContext(), 
> > e.toString(),
> > Toast.LENGTH_SHORT);
> >                 }
>
> >         }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to