【问题标题】:Error in when Displaying Status with twitter4j使用 twitter4j 显示状态时出错
【发布时间】:2012-01-24 18:56:39
【问题描述】:

运行 android 应用程序时出现这些错误:

我没有获得状态,而是获得了一种状态,即“JSON EXCEPTON”。 我也在 elogcat 中遇到了这些错误。

01-22 15:39:09.783:E/Twitter(468):检索推文时出错 01-22 15:39:09.783: E/Twitter(468): 404: 请求的 URI 无效或请求的资源(例如用户)不存在。 01-22 15:39:09.783: E/Twitter(468): {"error":"Not found","re​​quest":"/1/null/lists/0/statuses.json?page=1"}

这段代码运行良好。但是然后我将图标放在我的列表视图上(显示状态之前的菜单...)。我在这里的某个地方遇到了错误:

有什么想法吗?

    @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);

ImageView imageview =(ImageView)rowView.findViewById(R.id.last_build_stat);
try {
    String date = (String)jsonImageText.get("tweetDate");
    String avatar = (String)jsonImageText.get("avatar");
    imageview.setImageBitmap(getBitmap(avatar));
} catch (JSONException e) {

    e.printStackTrace();
}


    // Set the text on the TextView
    TextView textView = (TextView) rowView.findViewById(R.id.job_text);


    try {

        String tweet = (String)jsonImageText.get("tweet");

        String auth = (String)jsonImageText.get("author");

        //String date = (String)jsonImageText.get("tweetDate");

        if (date.length()>0){

            String latest = tweet + "<br><br><i>" + auth + " - " + date + "</i>";
            //String latest = tweet;
            textView.setText(Html.fromHtml(latest));
        } else {

            textView.setText(Html.fromHtml(tweet) + "\n" + Html.fromHtml(auth));
        }


    } catch (JSONException e) {

        textView.setText("JSON Exception");
    }

【问题讨论】:

    标签: android twitter twitter4j


    【解决方案1】:
    URI requested is invalid or the resource requested, such as a user, does not exists. 01-22 15:39:09.783: E/Twitter(468): {"error":"Not found","request":"/1/null/lists/0/statuses.json?page=1"}
    

    从该消息中可以明显看出,对 Twitter API 的调用失败。我建议在调用 Twitter API 之前添加一些打印语句并打印出您正在尝试的 URL。

    【讨论】:

      【解决方案2】:

      谢谢,我的菜单关键字需要大写..

      【讨论】:

        猜你喜欢
        • 2011-05-08
        • 1970-01-01
        • 2012-05-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多