Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6139641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:01:00+00:00 2026-05-23T18:01:00+00:00

I’m getting a json exception when I try to run my code. The problem

  • 0

I’m getting a json exception when I try to run my code.
The problem happens on the onclick listener. I’m trying to have the application go to the article of the rss feed on click

Here is the main activity

public class Blocku extends ListActivity {

private RssListAdapter adapter;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    List<JSONObject> jobs = new ArrayList<JSONObject>();
    try {
        jobs = BlockuReader.getLatestRssFeed();
    } catch (Exception e) {
        Log.e("RSS ERROR", "Error loading RSS Feed Stream >> " + e.getMessage() + " //" + e.toString());
    }

    adapter = new RssListAdapter(this,jobs);
    setListAdapter(adapter);
}

protected void onListItemClick(ListView l, View v, int position, long id) {
       super.onListItemClick(l, v, position, id);

       String link = null;
    try {
        String url = Article.getUrl().toString();

        link = adapter.getItem(position).getString(url).toString();
         Intent i = new Intent(Intent.ACTION_VIEW);
           i.setData(Uri.parse(link));
           startActivity(i);
    } catch (JSONException e) {
        Context context = getApplicationContext();
        CharSequence text = "error";
        int duration = Toast.LENGTH_SHORT;

        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
        e.printStackTrace();
    }

    }

}

here is the adapter:

public class RssListAdapter extends ArrayAdapter<JSONObject> {

public RssListAdapter(Activity activity, List<JSONObject> imageAndTexts) {
    super(activity, 0, imageAndTexts);
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Activity activity = (Activity) getContext();
    LayoutInflater inflater = activity.getLayoutInflater();

    // Inflate the views from XML
    View rowView = inflater.inflate(R.layout.image_text_layout, null);
    JSONObject jsonImageText = getItem(position);


    //////////////////////////////////////////////////////////////////////////////////////////////////////
    //The next section we update at runtime the text - as provided by the JSON from our REST call
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    TextView textView = (TextView) rowView.findViewById(R.id.job_text);

    try {
        Spanned text = (Spanned)jsonImageText.get("text");
        textView.setText(text);

    } catch (JSONException e) {
        textView.setText("JSON Exception");
    }

    return rowView;

} 


}

and the article class

public class Article {

private long articleId;
private long feedId;
private String title;
private String description;
private String pubDate;
private static URL url;
private String encodedContent;

private static String link;
/**
 * @return the articleId
 */
public long getArticleId() {
    return articleId;
}
/**
 * @param articleId the articleId to set
 */
public void setArticleId(long articleId) {
    this.articleId = articleId;
}
/**
 * @return the feedId
 */
public long getFeedId() {
    return feedId;
}
/**
 * @param feedId the feedId to set
 */
public void setFeedId(long feedId) {
    this.feedId = feedId;
}
/**
 * @return the title
 */
public String getTitle() {
    return title;
}
/**
 * @param title the title to set
 */
public void setTitle(String title) {
    this.title = title;
}
/**
 * @return the url
 */
public static  URL getUrl() {
    return url;
}
/**
 * @param url the url to set
 */
public void setUrl(URL url) {
    Article.url = url;
}
/**
 * @param description the description to set
 */
public void setDescription(String description) {
    this.description = description;
}
/**
 * @return the description
 */
public String getDescription() {
    return description;
}
/**
 * @param pubDate the pubDate to set
 */
public void setPubDate(String pubDate) {
    this.pubDate = pubDate;
}
/**
 * @return the pubDate
 */
public String getPubDate() {
    return pubDate;
}
/**
 * @param encodedContent the encodedContent to set
 */
public void setEncodedContent(String encodedContent) {
    this.encodedContent = encodedContent;
}
/**
 * @return the encodedContent
 */
public String getEncodedContent() {
    return encodedContent;
}


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:01:00+00:00Added an answer on May 23, 2026 at 6:01 pm

    JSONException is usually thrown when there are issues with parsing. Check how you are parsing the JSON. this says that you are trying to get a value for a key named “then it lists the site i want”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.