如何将 catch 块值传递给另一个 Activity?我的 Activity 在访问 URL 并在服务器忙或没有响应时获得 XML 响应时工作正常,如何将 catch 块语句传递给另一个 Activity?
public class AgAppHelperMethods
{
private static final String LOG_TAG = null;
public static String varMobileNo;
public static String varPinNo;
String[][] xmlRespone = null;
public static String[][] AgAppXMLParser( String parUrl)
{
String _node,_element;
String[][] xmlRespone = null;
HttpURLConnection urlConnection = null;
try
{
String url = parUrl;
URL finalUrl = new URL(url);
urlConnection = (HttpURLConnection) finalUrl.openConnection();
urlConnection.connect();
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new
InputSource(urlConnection.getInputStream()));
doc.getDocumentElement().normalize();
NodeList list=doc.getElementsByTagName("*");
_node=new String();
_element = new String();
xmlRespone = new String[list.getLength()][2];
for (int i=0;i<list.getLength();i++)
{
Node value=list.item(i).getChildNodes().item(0);
_node=list.item(i).getNodeName();
_element=value.getNodeValue();
xmlRespone[i][0] = _node;
xmlRespone[i][1] = _element;
}//end for
urlConnection.disconnect();
}//end try
catch (Exception e)
{
Log.e(LOG_TAG, "CONNECTION ERROR O SERVER NOT RESPONDING", e);
}
return xmlRespone;
}