由于某些原因,当我在AlertDialog的OnClickListener中启动一个新线程时,我的应用程序崩溃了。我尝试使用AsyncTask,但也没有用。有什么建议吗?
继承我的代码,先谢谢。
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Perform Operation? ");
builder.setPositiveButton("No", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});
builder.setNegativeButton("Yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
Thread thread = new Thread(new Runnable()
{
public void run()
{
//Perform network operations
}
});
thread.start();
}
});
AlertDialog dialog = builder.create();
dialog.show();