WebサービスのURLにヒットしてサーバから結果を取得する非同期タスクを使用していますが、解析例外が発生した場合はonPreExecute() ()メソッド、今私は、次の実行OnpostExecute()メソッドに行けない処理手段を停止したいので)(OnPostExecuteに 私のコードを、それを行くための実行プロセスを停止する方法例外の解析onpreexecute()が発生すると停止する
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(MainMenu.this);
dialog.setMessage("Processing...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
}
@Override
protected void onPostExecute(final Boolean success) {
if (dialog.isShowing())
{
dialog.dismiss();
}
Intent i = new Intent(MainMenu.this, filterpagetabs.class);
startActivity(i);
}
@Override
protected Boolean doInBackground(final String... args) {
try{
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
URL sourceUrl = new URL(
"http://www.mobi/iphonejh/output.php?estado=1");
MyXMLHandler myXMLHandler = new MyXMLHandler();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
}
下回っています
おかげでうまくそれが働く良い答え – shyam
のための+1 ...しかし...あなたはparsingSuccessfulのVARせずにこれを行うことができていることを確認するために... doInBackgroundはonPostExecuteに渡されるブール値を返します。 (...)を 'final Boolean success'として... – Selvin