I've developed an Android-application, which parses a web-page and as a result return pictures and texts from it. But when I show my application code to my customer, he said, he want me to write my application using more easy algorithm: application must find picture-urls and text-urls, and then show a content using founded urls. How to do it?
This a parsing class from my application:
public class NetworkConnect extends AsyncTask<String, Void, Void>
{
//Background processing
ProgressDialog parsingBar = ProgressDialog.show(StackParser.this, "Working...", "requesting to URL and parsing content", true, false);
protected Void doInBackground(String... arg)
{
try
{
Log.d(LOG_TAG, arg[0]);
Document doc;
Elements urls;
Elements data;
Intent intent = new Intent(StackParser.this, AvailableContent.class);
doc = Jsoup.connect(arg[0]).timeout(10000).get();
data = doc.getAllElements();
Log.d(LOG_TAG, "Data: " + data.toString());
stringData = doc.text();
Log.d(LOG_TAG, "String data: " + stringData.toString());
urls = doc.select("[href$=.png]");
imageURL = urls.get(0).attr("href");
Log.d(LOG_TAG, "imageURL = " + imageURL);
if(!stringData.equals(""))
{
intent.putExtra("Send to the content-activity", stringData);
intent.putExtra("Send imagesURLs to the content-activity", imageURL);
startActivity(intent);
finish();
}
else
{
intent.putExtra("Send to the content-activity", "empty");
startActivity(intent);
finish();
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} //catch (InterruptedException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
//}
return null;
}
protected void onPostExecute(Void result)
{
//Убираем диалог загрузки
parsingBar.dismiss();
}
}
}