在我正在使用的一项活动中AsyncTask
. In doInBackground()
我正在调用各种方法。在其中一种方法中,我遇到了异常,因此在 catch 块中我想在 Toast 中显示错误。
我知道我可以使用Log
但我还是更喜欢吐司。
那么,如何在 doInBackground() 中的 AsyncTask 中使用 Toast 呢?
从 doInBackground 返回为
protected String doInBackground(String... params){
//some code
try{
//some code
}catch(Exception e){
return "Exception Caught";
}
return someValidResult;
}
protected void onPostExecute(String result){
if(result.equalsIgnoreCase("Exception Caught")){
//Display Toast
}else{
// // whatever you wana do with valid result
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)