使用twitter4j显示状态时出错

时间:2012-01-22 15:51:39

标签: android twitter twitter4j

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

而不是获取状态我得到一个状态,说“JSON EXCEPTiON”。 我也在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”,“request”:“/ 1 / null / lists / 0 / statuses.json?page = 1”} < / p>

此代码运行良好。但是之后我在列表视图上放了图标(在显示状态之前的菜单......)。我在这里得到了错误:

有什么想法吗?

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

2 个答案:

答案 0 :(得分:0)

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之前输入一些print语句并打印出你正在尝试的URL。

答案 1 :(得分:0)

谢谢你想出我的菜单关键字必须是大写字母..