我试着把finish()方法用来阻止堆栈。但它给了我语法错误。我可以停止堆栈。谢谢提前。
private class getNewMessages extends AsyncTask<ApiConnector, Long, JSONArray> {
@Override
protected JSONArray doInBackground(ApiConnector... params) {
try {
JSONArray array = params[0].getMessage(name, password);
// String [] array=new String[10];
if (array.length() > 0) {
Intent nextScreen = new Intent(getApplicationContext(), bussiness.class);
nextScreen.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(nextScreen);
}
}catch (Exception e)
{
Toast.makeText(getApplicationContext(),"Wrong Credintials", Toast.LENGTH_SHORT).show();
}
return null;
}
@Override
protected void onPostExecute(JSONArray result) {
}
}
答案 0 :(得分:2)
将代码转移到onPostExecute回调
DatagramSocket
答案 1 :(得分:0)
尝试使用(Activity)mContext).finish();
或finish();