开发者

stop executing a function without exiting the application

开发者 https://www.devze.com 2023-04-04 17:45 出处:网络
Following is my code: try { usrID=client.callString(\"VerifyUsrnameAndPswd\", userName.getText().toString(), password.getText().toString());

Following is my code:

try 
{
    usrID=client.callString("VerifyUsrnameAndPswd", userName.getText().toString(), password.getText().toString());
}
catch (JSONRPCException e)
{
    Toast.makeText(this, "No internet connection", Toast.LENGTH_LONG).show();           
    Log.e("error", "client.callString exception: "+e.toString());
    e.printStackTrace();
// If this condition is true, then no need to go ahead
}
// some steps of remaining code

I do not want to execute the steps after the catch block, when there is no internet connection. But I don't even want to exit the application. Hence cannot use final().

Please suggest me some f开发者_运维问答unction to stop the further execution without exiting the application.


You shoud use continue or break or return in catch block depending where that code is.


One - you can use return statement.

Two - You can set a flag, and according to the flag, you can execute some code, or do nothing.


'return; finish;' can stop execution

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号