【发布时间】:2015-04-02 05:42:55
【问题描述】:
我们在 android studio 中使用 jsoup 解析实时 url 时遇到问题。相同的代码将在 eclipse 中运行。我们遇到错误
Method threw 'java.lang.NullPointerException' exception.can not evaluate org.jsoup.parser.HtmlTreebuilder.tostring()
这是我的活动代码
String title=null;
Document document;
try {
document= Jsoup.connect("https://www.facebook.com/")
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get();
title=document.title();
TextView text=(TextView)findViewById(R.id.textView);
text.setText(title);
} catch (Exception e) {
e.printStackTrace();
Log.d("tag","document");
}
如何解决这个问题并从实时 url 中获取标题?
【问题讨论】:
-
也基于该问题的 cmets:你确定你在 android-studio 和 eclipse 中使用相同版本的 jsoup 吗?
-
我正在使用相同版本的jsoup最新1.8.1.help e来解决这个问题
-
@Pshemo stackoverflow.com/questions/29390379/… 现在看看
标签: java html parsing android-studio jsoup