我有一个class
不扩展的Activity
. 在那堂课中,我使用一个try-catch
块来捕捉exceptions
. 如何将Exception e
在该块中捕获的任何异常()传递给另一个Activity
?我的应用程序使用 a 检查boolean flag
以显示toast message
. 但是我如何将此消息传递给另一个活动?
public class AgAppHelperMethods {
private static AgAppHelperMethods instance = null;
static boolean flag=true;
public static String[][] AgAppXMLParser( String parUrl) {
String _node,_element;
String[][] xmlRespone = null;
try {
String url = www.xyz.com
URL finalUrl = new URL(url);
catch (Exception e)
{
flag=false;
Log.e( "CONNECTION ERROR SERVER NOT RESPONDING", e);
}
public class LoginScreen extends Activity implements Serializable {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.agapplogin);
btnClear.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
postLoginData();
}
});
public void postLoginData()
{
xmlRespone = AgAppHelperMethods.AgAppXMLParser( url);
if(!AgAppHelperMethods.flag)
{
Toast.makeText(getApplicationContext(), "Error server
not responding " , Toast.LENGTH_SHORT).show();
myProgressDialog.dismiss();
}