aka, what is wrong with this code:-
package com.mez.appofjaq;
import com.mez.appofjaq.RssParser.RssFeed;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.webkit.WebView;
public class AppOfJaq extends Activity {
protected static final int REFRESH = 0;
String streamTitle = "";
protected ProgressDialog pd;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
pd.show(this, "Loading..", "Loading Feed");
setContentView(R.layout.main);
new Thread(new Runnable(){
public void run() {
loadFeed();
pd.dismiss();
}
}).start();
}
private void loadFeed()
{
RssParser rp = new RssParser("http://shotofjaq.org/feed");
rp.parse();
RssFeed feed = rp.getFeed();
if (feed.getItems() != null)
{
streamTitle = feed.getItems().get(0).content;
}
WebView result = (WebView)findViewById(R.id.result);
result.loadData(streamTitle, "text/html", "utf-8");
}
}
Macarse and alex are both right (and both missing information).
Macarse’s code is what you need to use to get it to work. It includes the missing parameter (the
trueat the end to make it an indeterminate dialog) and it fixes the Null Pointer Exception (NPE) by calling ProgressDialog.show instead of pd.show.I know this isn’t exactly an answer on its own, but I thought it would help someone else to know why both alex and Macarse are correct with their answers.
The end result is that you should have the following code, for the reasons above:
or this (if using strings.xml for your strings):